
obj/user/testpteshare.debug:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 6b 01 00 00       	call   80019c <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>

00800033 <childofspawn>:
	breakpoint();
}

void
childofspawn(void)
{
  800033:	f3 0f 1e fb          	endbr32 
  800037:	55                   	push   %ebp
  800038:	89 e5                	mov    %esp,%ebp
  80003a:	83 ec 10             	sub    $0x10,%esp
	strcpy(VA, msg2);
  80003d:	ff 35 00 40 80 00    	pushl  0x804000
  800043:	68 00 00 00 a0       	push   $0xa0000000
  800048:	e8 81 08 00 00       	call   8008ce <strcpy>
	exit();
  80004d:	e8 9e 01 00 00       	call   8001f0 <exit>
}
  800052:	83 c4 10             	add    $0x10,%esp
  800055:	c9                   	leave  
  800056:	c3                   	ret    

00800057 <umain>:
{
  800057:	f3 0f 1e fb          	endbr32 
  80005b:	55                   	push   %ebp
  80005c:	89 e5                	mov    %esp,%ebp
  80005e:	53                   	push   %ebx
  80005f:	83 ec 04             	sub    $0x4,%esp
	if (argc != 0)
  800062:	83 7d 08 00          	cmpl   $0x0,0x8(%ebp)
  800066:	0f 85 d0 00 00 00    	jne    80013c <umain+0xe5>
	if ((r = sys_page_alloc(0, VA, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80006c:	83 ec 04             	sub    $0x4,%esp
  80006f:	68 07 04 00 00       	push   $0x407
  800074:	68 00 00 00 a0       	push   $0xa0000000
  800079:	6a 00                	push   $0x0
  80007b:	e8 90 0c 00 00       	call   800d10 <sys_page_alloc>
  800080:	83 c4 10             	add    $0x10,%esp
  800083:	85 c0                	test   %eax,%eax
  800085:	0f 88 bb 00 00 00    	js     800146 <umain+0xef>
	if ((r = fork()) < 0)
  80008b:	e8 b7 0f 00 00       	call   801047 <fork>
  800090:	89 c3                	mov    %eax,%ebx
  800092:	85 c0                	test   %eax,%eax
  800094:	0f 88 be 00 00 00    	js     800158 <umain+0x101>
	if (r == 0) {
  80009a:	0f 84 ca 00 00 00    	je     80016a <umain+0x113>
	wait(r);
  8000a0:	83 ec 0c             	sub    $0xc,%esp
  8000a3:	53                   	push   %ebx
  8000a4:	e8 75 23 00 00       	call   80241e <wait>
	cprintf("fork handles PTE_SHARE %s\n", strcmp(VA, msg) == 0 ? "right" : "wrong");
  8000a9:	83 c4 08             	add    $0x8,%esp
  8000ac:	ff 35 04 40 80 00    	pushl  0x804004
  8000b2:	68 00 00 00 a0       	push   $0xa0000000
  8000b7:	e8 d1 08 00 00       	call   80098d <strcmp>
  8000bc:	83 c4 08             	add    $0x8,%esp
  8000bf:	85 c0                	test   %eax,%eax
  8000c1:	b8 60 2a 80 00       	mov    $0x802a60,%eax
  8000c6:	ba 66 2a 80 00       	mov    $0x802a66,%edx
  8000cb:	0f 45 c2             	cmovne %edx,%eax
  8000ce:	50                   	push   %eax
  8000cf:	68 9c 2a 80 00       	push   $0x802a9c
  8000d4:	e8 1c 02 00 00       	call   8002f5 <cprintf>
	if ((r = spawnl("/testpteshare", "testpteshare", "arg", 0)) < 0)
  8000d9:	6a 00                	push   $0x0
  8000db:	68 b7 2a 80 00       	push   $0x802ab7
  8000e0:	68 bc 2a 80 00       	push   $0x802abc
  8000e5:	68 bb 2a 80 00       	push   $0x802abb
  8000ea:	e8 17 1f 00 00       	call   802006 <spawnl>
  8000ef:	83 c4 20             	add    $0x20,%esp
  8000f2:	85 c0                	test   %eax,%eax
  8000f4:	0f 88 90 00 00 00    	js     80018a <umain+0x133>
	wait(r);
  8000fa:	83 ec 0c             	sub    $0xc,%esp
  8000fd:	50                   	push   %eax
  8000fe:	e8 1b 23 00 00       	call   80241e <wait>
	cprintf("spawn handles PTE_SHARE %s\n", strcmp(VA, msg2) == 0 ? "right" : "wrong");
  800103:	83 c4 08             	add    $0x8,%esp
  800106:	ff 35 00 40 80 00    	pushl  0x804000
  80010c:	68 00 00 00 a0       	push   $0xa0000000
  800111:	e8 77 08 00 00       	call   80098d <strcmp>
  800116:	83 c4 08             	add    $0x8,%esp
  800119:	85 c0                	test   %eax,%eax
  80011b:	b8 60 2a 80 00       	mov    $0x802a60,%eax
  800120:	ba 66 2a 80 00       	mov    $0x802a66,%edx
  800125:	0f 45 c2             	cmovne %edx,%eax
  800128:	50                   	push   %eax
  800129:	68 d3 2a 80 00       	push   $0x802ad3
  80012e:	e8 c2 01 00 00       	call   8002f5 <cprintf>
#include <inc/types.h>

static inline void
breakpoint(void)
{
	asm volatile("int3");
  800133:	cc                   	int3   
}
  800134:	83 c4 10             	add    $0x10,%esp
  800137:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  80013a:	c9                   	leave  
  80013b:	c3                   	ret    
		childofspawn();
  80013c:	e8 f2 fe ff ff       	call   800033 <childofspawn>
  800141:	e9 26 ff ff ff       	jmp    80006c <umain+0x15>
		panic("sys_page_alloc: %e", r);
  800146:	50                   	push   %eax
  800147:	68 6c 2a 80 00       	push   $0x802a6c
  80014c:	6a 13                	push   $0x13
  80014e:	68 7f 2a 80 00       	push   $0x802a7f
  800153:	e8 b6 00 00 00       	call   80020e <_panic>
		panic("fork: %e", r);
  800158:	50                   	push   %eax
  800159:	68 93 2a 80 00       	push   $0x802a93
  80015e:	6a 17                	push   $0x17
  800160:	68 7f 2a 80 00       	push   $0x802a7f
  800165:	e8 a4 00 00 00       	call   80020e <_panic>
		strcpy(VA, msg);
  80016a:	83 ec 08             	sub    $0x8,%esp
  80016d:	ff 35 04 40 80 00    	pushl  0x804004
  800173:	68 00 00 00 a0       	push   $0xa0000000
  800178:	e8 51 07 00 00       	call   8008ce <strcpy>
		exit();
  80017d:	e8 6e 00 00 00       	call   8001f0 <exit>
  800182:	83 c4 10             	add    $0x10,%esp
  800185:	e9 16 ff ff ff       	jmp    8000a0 <umain+0x49>
		panic("spawn: %e", r);
  80018a:	50                   	push   %eax
  80018b:	68 c9 2a 80 00       	push   $0x802ac9
  800190:	6a 21                	push   $0x21
  800192:	68 7f 2a 80 00       	push   $0x802a7f
  800197:	e8 72 00 00 00       	call   80020e <_panic>

0080019c <libmain>:
const volatile struct Env *thisenv;
const char *binaryname = "<unknown>";

void
libmain(int argc, char **argv)
{
  80019c:	f3 0f 1e fb          	endbr32 
  8001a0:	55                   	push   %ebp
  8001a1:	89 e5                	mov    %esp,%ebp
  8001a3:	56                   	push   %esi
  8001a4:	53                   	push   %ebx
  8001a5:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8001a8:	8b 75 0c             	mov    0xc(%ebp),%esi
	;    //系统调用，我们已经在Exercise 7中实现了
	
	
	
	//屏幕上打印出来了字母，但后续报错了，有意思，让我看看问题出现在哪。
	thisenv=0;
  8001ab:	c7 05 04 50 80 00 00 	movl   $0x0,0x805004
  8001b2:	00 00 00 
	thisenv = &envs[ENVX(sys_getenvid())];      //获取Env结构指针
  8001b5:	e8 10 0b 00 00       	call   800cca <sys_getenvid>
  8001ba:	25 ff 03 00 00       	and    $0x3ff,%eax
  8001bf:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8001c2:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8001c7:	a3 04 50 80 00       	mov    %eax,0x805004

	// save the name of the program so that panic() can use it
	if (argc > 0)
  8001cc:	85 db                	test   %ebx,%ebx
  8001ce:	7e 07                	jle    8001d7 <libmain+0x3b>
		binaryname = argv[0];
  8001d0:	8b 06                	mov    (%esi),%eax
  8001d2:	a3 08 40 80 00       	mov    %eax,0x804008

	// call user main routine
	umain(argc, argv);
  8001d7:	83 ec 08             	sub    $0x8,%esp
  8001da:	56                   	push   %esi
  8001db:	53                   	push   %ebx
  8001dc:	e8 76 fe ff ff       	call   800057 <umain>

	// exit gracefully
	exit();
  8001e1:	e8 0a 00 00 00       	call   8001f0 <exit>
}
  8001e6:	83 c4 10             	add    $0x10,%esp
  8001e9:	8d 65 f8             	lea    -0x8(%ebp),%esp
  8001ec:	5b                   	pop    %ebx
  8001ed:	5e                   	pop    %esi
  8001ee:	5d                   	pop    %ebp
  8001ef:	c3                   	ret    

008001f0 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  8001f0:	f3 0f 1e fb          	endbr32 
  8001f4:	55                   	push   %ebp
  8001f5:	89 e5                	mov    %esp,%ebp
  8001f7:	83 ec 08             	sub    $0x8,%esp
	close_all();
  8001fa:	e8 52 12 00 00       	call   801451 <close_all>
	sys_env_destroy(0);
  8001ff:	83 ec 0c             	sub    $0xc,%esp
  800202:	6a 00                	push   $0x0
  800204:	e8 7c 0a 00 00       	call   800c85 <sys_env_destroy>
}
  800209:	83 c4 10             	add    $0x10,%esp
  80020c:	c9                   	leave  
  80020d:	c3                   	ret    

0080020e <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt, ...)
{
  80020e:	f3 0f 1e fb          	endbr32 
  800212:	55                   	push   %ebp
  800213:	89 e5                	mov    %esp,%ebp
  800215:	56                   	push   %esi
  800216:	53                   	push   %ebx
	va_list ap;

	va_start(ap, fmt);
  800217:	8d 5d 14             	lea    0x14(%ebp),%ebx

	// Print the panic message
	cprintf("[%08x] user panic in %s at %s:%d: ",
  80021a:	8b 35 08 40 80 00    	mov    0x804008,%esi
  800220:	e8 a5 0a 00 00       	call   800cca <sys_getenvid>
  800225:	83 ec 0c             	sub    $0xc,%esp
  800228:	ff 75 0c             	pushl  0xc(%ebp)
  80022b:	ff 75 08             	pushl  0x8(%ebp)
  80022e:	56                   	push   %esi
  80022f:	50                   	push   %eax
  800230:	68 18 2b 80 00       	push   $0x802b18
  800235:	e8 bb 00 00 00       	call   8002f5 <cprintf>
		sys_getenvid(), binaryname, file, line);
	vcprintf(fmt, ap);
  80023a:	83 c4 18             	add    $0x18,%esp
  80023d:	53                   	push   %ebx
  80023e:	ff 75 10             	pushl  0x10(%ebp)
  800241:	e8 5a 00 00 00       	call   8002a0 <vcprintf>
	cprintf("\n");
  800246:	c7 04 24 2e 31 80 00 	movl   $0x80312e,(%esp)
  80024d:	e8 a3 00 00 00       	call   8002f5 <cprintf>
  800252:	83 c4 10             	add    $0x10,%esp

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800255:	cc                   	int3   
  800256:	eb fd                	jmp    800255 <_panic+0x47>

00800258 <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  800258:	f3 0f 1e fb          	endbr32 
  80025c:	55                   	push   %ebp
  80025d:	89 e5                	mov    %esp,%ebp
  80025f:	53                   	push   %ebx
  800260:	83 ec 04             	sub    $0x4,%esp
  800263:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800266:	8b 13                	mov    (%ebx),%edx
  800268:	8d 42 01             	lea    0x1(%edx),%eax
  80026b:	89 03                	mov    %eax,(%ebx)
  80026d:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800270:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
	if (b->idx == 256-1) {
  800274:	3d ff 00 00 00       	cmp    $0xff,%eax
  800279:	74 09                	je     800284 <putch+0x2c>
		sys_cputs(b->buf, b->idx);
		b->idx = 0;
	}
	b->cnt++;
  80027b:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80027f:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  800282:	c9                   	leave  
  800283:	c3                   	ret    
		sys_cputs(b->buf, b->idx);
  800284:	83 ec 08             	sub    $0x8,%esp
  800287:	68 ff 00 00 00       	push   $0xff
  80028c:	8d 43 08             	lea    0x8(%ebx),%eax
  80028f:	50                   	push   %eax
  800290:	e8 ab 09 00 00       	call   800c40 <sys_cputs>
		b->idx = 0;
  800295:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  80029b:	83 c4 10             	add    $0x10,%esp
  80029e:	eb db                	jmp    80027b <putch+0x23>

008002a0 <vcprintf>:

int
vcprintf(const char *fmt, va_list ap)
{
  8002a0:	f3 0f 1e fb          	endbr32 
  8002a4:	55                   	push   %ebp
  8002a5:	89 e5                	mov    %esp,%ebp
  8002a7:	81 ec 18 01 00 00    	sub    $0x118,%esp
	struct printbuf b;

	b.idx = 0;
  8002ad:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8002b4:	00 00 00 
	b.cnt = 0;
  8002b7:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  8002be:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  8002c1:	ff 75 0c             	pushl  0xc(%ebp)
  8002c4:	ff 75 08             	pushl  0x8(%ebp)
  8002c7:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  8002cd:	50                   	push   %eax
  8002ce:	68 58 02 80 00       	push   $0x800258
  8002d3:	e8 20 01 00 00       	call   8003f8 <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8002d8:	83 c4 08             	add    $0x8,%esp
  8002db:	ff b5 f0 fe ff ff    	pushl  -0x110(%ebp)
  8002e1:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8002e7:	50                   	push   %eax
  8002e8:	e8 53 09 00 00       	call   800c40 <sys_cputs>

	return b.cnt;
}
  8002ed:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8002f3:	c9                   	leave  
  8002f4:	c3                   	ret    

008002f5 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  8002f5:	f3 0f 1e fb          	endbr32 
  8002f9:	55                   	push   %ebp
  8002fa:	89 e5                	mov    %esp,%ebp
  8002fc:	83 ec 10             	sub    $0x10,%esp
	va_list ap;
	int cnt;

	va_start(ap, fmt);
  8002ff:	8d 45 0c             	lea    0xc(%ebp),%eax
	cnt = vcprintf(fmt, ap);
  800302:	50                   	push   %eax
  800303:	ff 75 08             	pushl  0x8(%ebp)
  800306:	e8 95 ff ff ff       	call   8002a0 <vcprintf>
	va_end(ap);

	return cnt;
}
  80030b:	c9                   	leave  
  80030c:	c3                   	ret    

0080030d <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  80030d:	55                   	push   %ebp
  80030e:	89 e5                	mov    %esp,%ebp
  800310:	57                   	push   %edi
  800311:	56                   	push   %esi
  800312:	53                   	push   %ebx
  800313:	83 ec 1c             	sub    $0x1c,%esp
  800316:	89 c7                	mov    %eax,%edi
  800318:	89 d6                	mov    %edx,%esi
  80031a:	8b 45 08             	mov    0x8(%ebp),%eax
  80031d:	8b 55 0c             	mov    0xc(%ebp),%edx
  800320:	89 d1                	mov    %edx,%ecx
  800322:	89 c2                	mov    %eax,%edx
  800324:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800327:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  80032a:	8b 45 10             	mov    0x10(%ebp),%eax
  80032d:	8b 5d 14             	mov    0x14(%ebp),%ebx
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800330:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800333:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  80033a:	39 c2                	cmp    %eax,%edx
  80033c:	1b 4d e4             	sbb    -0x1c(%ebp),%ecx
  80033f:	72 3e                	jb     80037f <printnum+0x72>
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800341:	83 ec 0c             	sub    $0xc,%esp
  800344:	ff 75 18             	pushl  0x18(%ebp)
  800347:	83 eb 01             	sub    $0x1,%ebx
  80034a:	53                   	push   %ebx
  80034b:	50                   	push   %eax
  80034c:	83 ec 08             	sub    $0x8,%esp
  80034f:	ff 75 e4             	pushl  -0x1c(%ebp)
  800352:	ff 75 e0             	pushl  -0x20(%ebp)
  800355:	ff 75 dc             	pushl  -0x24(%ebp)
  800358:	ff 75 d8             	pushl  -0x28(%ebp)
  80035b:	e8 a0 24 00 00       	call   802800 <__udivdi3>
  800360:	83 c4 18             	add    $0x18,%esp
  800363:	52                   	push   %edx
  800364:	50                   	push   %eax
  800365:	89 f2                	mov    %esi,%edx
  800367:	89 f8                	mov    %edi,%eax
  800369:	e8 9f ff ff ff       	call   80030d <printnum>
  80036e:	83 c4 20             	add    $0x20,%esp
  800371:	eb 13                	jmp    800386 <printnum+0x79>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800373:	83 ec 08             	sub    $0x8,%esp
  800376:	56                   	push   %esi
  800377:	ff 75 18             	pushl  0x18(%ebp)
  80037a:	ff d7                	call   *%edi
  80037c:	83 c4 10             	add    $0x10,%esp
		while (--width > 0)
  80037f:	83 eb 01             	sub    $0x1,%ebx
  800382:	85 db                	test   %ebx,%ebx
  800384:	7f ed                	jg     800373 <printnum+0x66>
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800386:	83 ec 08             	sub    $0x8,%esp
  800389:	56                   	push   %esi
  80038a:	83 ec 04             	sub    $0x4,%esp
  80038d:	ff 75 e4             	pushl  -0x1c(%ebp)
  800390:	ff 75 e0             	pushl  -0x20(%ebp)
  800393:	ff 75 dc             	pushl  -0x24(%ebp)
  800396:	ff 75 d8             	pushl  -0x28(%ebp)
  800399:	e8 72 25 00 00       	call   802910 <__umoddi3>
  80039e:	83 c4 14             	add    $0x14,%esp
  8003a1:	0f be 80 3b 2b 80 00 	movsbl 0x802b3b(%eax),%eax
  8003a8:	50                   	push   %eax
  8003a9:	ff d7                	call   *%edi
}
  8003ab:	83 c4 10             	add    $0x10,%esp
  8003ae:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8003b1:	5b                   	pop    %ebx
  8003b2:	5e                   	pop    %esi
  8003b3:	5f                   	pop    %edi
  8003b4:	5d                   	pop    %ebp
  8003b5:	c3                   	ret    

008003b6 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  8003b6:	f3 0f 1e fb          	endbr32 
  8003ba:	55                   	push   %ebp
  8003bb:	89 e5                	mov    %esp,%ebp
  8003bd:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  8003c0:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  8003c4:	8b 10                	mov    (%eax),%edx
  8003c6:	3b 50 04             	cmp    0x4(%eax),%edx
  8003c9:	73 0a                	jae    8003d5 <sprintputch+0x1f>
		*b->buf++ = ch;
  8003cb:	8d 4a 01             	lea    0x1(%edx),%ecx
  8003ce:	89 08                	mov    %ecx,(%eax)
  8003d0:	8b 45 08             	mov    0x8(%ebp),%eax
  8003d3:	88 02                	mov    %al,(%edx)
}
  8003d5:	5d                   	pop    %ebp
  8003d6:	c3                   	ret    

008003d7 <printfmt>:
{
  8003d7:	f3 0f 1e fb          	endbr32 
  8003db:	55                   	push   %ebp
  8003dc:	89 e5                	mov    %esp,%ebp
  8003de:	83 ec 08             	sub    $0x8,%esp
	va_start(ap, fmt);
  8003e1:	8d 45 14             	lea    0x14(%ebp),%eax
	vprintfmt(putch, putdat, fmt, ap);
  8003e4:	50                   	push   %eax
  8003e5:	ff 75 10             	pushl  0x10(%ebp)
  8003e8:	ff 75 0c             	pushl  0xc(%ebp)
  8003eb:	ff 75 08             	pushl  0x8(%ebp)
  8003ee:	e8 05 00 00 00       	call   8003f8 <vprintfmt>
}
  8003f3:	83 c4 10             	add    $0x10,%esp
  8003f6:	c9                   	leave  
  8003f7:	c3                   	ret    

008003f8 <vprintfmt>:
{
  8003f8:	f3 0f 1e fb          	endbr32 
  8003fc:	55                   	push   %ebp
  8003fd:	89 e5                	mov    %esp,%ebp
  8003ff:	57                   	push   %edi
  800400:	56                   	push   %esi
  800401:	53                   	push   %ebx
  800402:	83 ec 3c             	sub    $0x3c,%esp
  800405:	8b 75 08             	mov    0x8(%ebp),%esi
  800408:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  80040b:	8b 7d 10             	mov    0x10(%ebp),%edi
  80040e:	e9 5d 03 00 00       	jmp    800770 <vprintfmt+0x378>
		padc = ' ';
  800413:	c6 45 d3 20          	movb   $0x20,-0x2d(%ebp)
		altflag = 0;
  800417:	c7 45 e0 00 00 00 00 	movl   $0x0,-0x20(%ebp)
		precision = -1;
  80041e:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
		width = -1;
  800425:	c7 45 d4 ff ff ff ff 	movl   $0xffffffff,-0x2c(%ebp)
		lflag = 0;
  80042c:	b9 00 00 00 00       	mov    $0x0,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  800431:	8d 47 01             	lea    0x1(%edi),%eax
  800434:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  800437:	0f b6 17             	movzbl (%edi),%edx
  80043a:	8d 42 dd             	lea    -0x23(%edx),%eax
  80043d:	3c 55                	cmp    $0x55,%al
  80043f:	0f 87 ae 03 00 00    	ja     8007f3 <vprintfmt+0x3fb>
  800445:	0f b6 c0             	movzbl %al,%eax
  800448:	3e ff 24 85 80 2c 80 	notrack jmp *0x802c80(,%eax,4)
  80044f:	00 
  800450:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			padc = '-';
  800453:	c6 45 d3 2d          	movb   $0x2d,-0x2d(%ebp)
  800457:	eb d8                	jmp    800431 <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  800459:	8b 7d e4             	mov    -0x1c(%ebp),%edi
  80045c:	c6 45 d3 30          	movb   $0x30,-0x2d(%ebp)
  800460:	eb cf                	jmp    800431 <vprintfmt+0x39>
  800462:	0f b6 d2             	movzbl %dl,%edx
  800465:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			for (precision = 0; ; ++fmt) {
  800468:	b8 00 00 00 00       	mov    $0x0,%eax
  80046d:	89 4d e4             	mov    %ecx,-0x1c(%ebp)
				precision = precision * 10 + ch - '0';
  800470:	8d 04 80             	lea    (%eax,%eax,4),%eax
  800473:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
				ch = *fmt;
  800477:	0f be 17             	movsbl (%edi),%edx
				if (ch < '0' || ch > '9')
  80047a:	8d 4a d0             	lea    -0x30(%edx),%ecx
  80047d:	83 f9 09             	cmp    $0x9,%ecx
  800480:	77 55                	ja     8004d7 <vprintfmt+0xdf>
			for (precision = 0; ; ++fmt) {
  800482:	83 c7 01             	add    $0x1,%edi
				precision = precision * 10 + ch - '0';
  800485:	eb e9                	jmp    800470 <vprintfmt+0x78>
			precision = va_arg(ap, int);
  800487:	8b 45 14             	mov    0x14(%ebp),%eax
  80048a:	8b 00                	mov    (%eax),%eax
  80048c:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80048f:	8b 45 14             	mov    0x14(%ebp),%eax
  800492:	8d 40 04             	lea    0x4(%eax),%eax
  800495:	89 45 14             	mov    %eax,0x14(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  800498:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			if (width < 0)
  80049b:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  80049f:	79 90                	jns    800431 <vprintfmt+0x39>
				width = precision, precision = -1;
  8004a1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8004a4:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  8004a7:	c7 45 d8 ff ff ff ff 	movl   $0xffffffff,-0x28(%ebp)
  8004ae:	eb 81                	jmp    800431 <vprintfmt+0x39>
  8004b0:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8004b3:	85 c0                	test   %eax,%eax
  8004b5:	ba 00 00 00 00       	mov    $0x0,%edx
  8004ba:	0f 49 d0             	cmovns %eax,%edx
  8004bd:	89 55 d4             	mov    %edx,-0x2c(%ebp)
		switch (ch = *(unsigned char *) fmt++) {
  8004c0:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  8004c3:	e9 69 ff ff ff       	jmp    800431 <vprintfmt+0x39>
		switch (ch = *(unsigned char *) fmt++) {
  8004c8:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			altflag = 1;
  8004cb:	c7 45 e0 01 00 00 00 	movl   $0x1,-0x20(%ebp)
			goto reswitch;
  8004d2:	e9 5a ff ff ff       	jmp    800431 <vprintfmt+0x39>
  8004d7:	8b 4d e4             	mov    -0x1c(%ebp),%ecx
  8004da:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8004dd:	eb bc                	jmp    80049b <vprintfmt+0xa3>
			lflag++;
  8004df:	83 c1 01             	add    $0x1,%ecx
		switch (ch = *(unsigned char *) fmt++) {
  8004e2:	8b 7d e4             	mov    -0x1c(%ebp),%edi
			goto reswitch;
  8004e5:	e9 47 ff ff ff       	jmp    800431 <vprintfmt+0x39>
			putch(va_arg(ap, int), putdat);
  8004ea:	8b 45 14             	mov    0x14(%ebp),%eax
  8004ed:	8d 78 04             	lea    0x4(%eax),%edi
  8004f0:	83 ec 08             	sub    $0x8,%esp
  8004f3:	53                   	push   %ebx
  8004f4:	ff 30                	pushl  (%eax)
  8004f6:	ff d6                	call   *%esi
			break;
  8004f8:	83 c4 10             	add    $0x10,%esp
			putch(va_arg(ap, int), putdat);
  8004fb:	89 7d 14             	mov    %edi,0x14(%ebp)
			break;
  8004fe:	e9 6a 02 00 00       	jmp    80076d <vprintfmt+0x375>
			err = va_arg(ap, int);
  800503:	8b 45 14             	mov    0x14(%ebp),%eax
  800506:	8d 78 04             	lea    0x4(%eax),%edi
  800509:	8b 00                	mov    (%eax),%eax
  80050b:	99                   	cltd   
  80050c:	31 d0                	xor    %edx,%eax
  80050e:	29 d0                	sub    %edx,%eax
			if (err >= MAXERROR || (p = error_string[err]) == NULL)
  800510:	83 f8 0f             	cmp    $0xf,%eax
  800513:	7f 23                	jg     800538 <vprintfmt+0x140>
  800515:	8b 14 85 e0 2d 80 00 	mov    0x802de0(,%eax,4),%edx
  80051c:	85 d2                	test   %edx,%edx
  80051e:	74 18                	je     800538 <vprintfmt+0x140>
				printfmt(putch, putdat, "%s", p);
  800520:	52                   	push   %edx
  800521:	68 61 30 80 00       	push   $0x803061
  800526:	53                   	push   %ebx
  800527:	56                   	push   %esi
  800528:	e8 aa fe ff ff       	call   8003d7 <printfmt>
  80052d:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  800530:	89 7d 14             	mov    %edi,0x14(%ebp)
  800533:	e9 35 02 00 00       	jmp    80076d <vprintfmt+0x375>
				printfmt(putch, putdat, "error %d", err);
  800538:	50                   	push   %eax
  800539:	68 53 2b 80 00       	push   $0x802b53
  80053e:	53                   	push   %ebx
  80053f:	56                   	push   %esi
  800540:	e8 92 fe ff ff       	call   8003d7 <printfmt>
  800545:	83 c4 10             	add    $0x10,%esp
			err = va_arg(ap, int);
  800548:	89 7d 14             	mov    %edi,0x14(%ebp)
				printfmt(putch, putdat, "error %d", err);
  80054b:	e9 1d 02 00 00       	jmp    80076d <vprintfmt+0x375>
			if ((p = va_arg(ap, char *)) == NULL)
  800550:	8b 45 14             	mov    0x14(%ebp),%eax
  800553:	83 c0 04             	add    $0x4,%eax
  800556:	89 45 c8             	mov    %eax,-0x38(%ebp)
  800559:	8b 45 14             	mov    0x14(%ebp),%eax
  80055c:	8b 10                	mov    (%eax),%edx
				p = "(null)";
  80055e:	85 d2                	test   %edx,%edx
  800560:	b8 4c 2b 80 00       	mov    $0x802b4c,%eax
  800565:	0f 45 c2             	cmovne %edx,%eax
  800568:	89 45 cc             	mov    %eax,-0x34(%ebp)
			if (width > 0 && padc != '-')
  80056b:	83 7d d4 00          	cmpl   $0x0,-0x2c(%ebp)
  80056f:	7e 06                	jle    800577 <vprintfmt+0x17f>
  800571:	80 7d d3 2d          	cmpb   $0x2d,-0x2d(%ebp)
  800575:	75 0d                	jne    800584 <vprintfmt+0x18c>
				for (width -= strnlen(p, precision); width > 0; width--)
  800577:	8b 45 cc             	mov    -0x34(%ebp),%eax
  80057a:	89 c7                	mov    %eax,%edi
  80057c:	03 45 d4             	add    -0x2c(%ebp),%eax
  80057f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
  800582:	eb 55                	jmp    8005d9 <vprintfmt+0x1e1>
  800584:	83 ec 08             	sub    $0x8,%esp
  800587:	ff 75 d8             	pushl  -0x28(%ebp)
  80058a:	ff 75 cc             	pushl  -0x34(%ebp)
  80058d:	e8 15 03 00 00       	call   8008a7 <strnlen>
  800592:	8b 55 d4             	mov    -0x2c(%ebp),%edx
  800595:	29 c2                	sub    %eax,%edx
  800597:	89 55 c4             	mov    %edx,-0x3c(%ebp)
  80059a:	83 c4 10             	add    $0x10,%esp
  80059d:	89 d7                	mov    %edx,%edi
					putch(padc, putdat);
  80059f:	0f be 45 d3          	movsbl -0x2d(%ebp),%eax
  8005a3:	89 45 d4             	mov    %eax,-0x2c(%ebp)
				for (width -= strnlen(p, precision); width > 0; width--)
  8005a6:	85 ff                	test   %edi,%edi
  8005a8:	7e 11                	jle    8005bb <vprintfmt+0x1c3>
					putch(padc, putdat);
  8005aa:	83 ec 08             	sub    $0x8,%esp
  8005ad:	53                   	push   %ebx
  8005ae:	ff 75 d4             	pushl  -0x2c(%ebp)
  8005b1:	ff d6                	call   *%esi
				for (width -= strnlen(p, precision); width > 0; width--)
  8005b3:	83 ef 01             	sub    $0x1,%edi
  8005b6:	83 c4 10             	add    $0x10,%esp
  8005b9:	eb eb                	jmp    8005a6 <vprintfmt+0x1ae>
  8005bb:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  8005be:	85 d2                	test   %edx,%edx
  8005c0:	b8 00 00 00 00       	mov    $0x0,%eax
  8005c5:	0f 49 c2             	cmovns %edx,%eax
  8005c8:	29 c2                	sub    %eax,%edx
  8005ca:	89 55 d4             	mov    %edx,-0x2c(%ebp)
  8005cd:	eb a8                	jmp    800577 <vprintfmt+0x17f>
					putch(ch, putdat);
  8005cf:	83 ec 08             	sub    $0x8,%esp
  8005d2:	53                   	push   %ebx
  8005d3:	52                   	push   %edx
  8005d4:	ff d6                	call   *%esi
  8005d6:	83 c4 10             	add    $0x10,%esp
  8005d9:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
  8005dc:	29 f9                	sub    %edi,%ecx
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8005de:	83 c7 01             	add    $0x1,%edi
  8005e1:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  8005e5:	0f be d0             	movsbl %al,%edx
  8005e8:	85 d2                	test   %edx,%edx
  8005ea:	74 4b                	je     800637 <vprintfmt+0x23f>
  8005ec:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8005f0:	78 06                	js     8005f8 <vprintfmt+0x200>
  8005f2:	83 6d d8 01          	subl   $0x1,-0x28(%ebp)
  8005f6:	78 1e                	js     800616 <vprintfmt+0x21e>
				if (altflag && (ch < ' ' || ch > '~'))
  8005f8:	83 7d e0 00          	cmpl   $0x0,-0x20(%ebp)
  8005fc:	74 d1                	je     8005cf <vprintfmt+0x1d7>
  8005fe:	0f be c0             	movsbl %al,%eax
  800601:	83 e8 20             	sub    $0x20,%eax
  800604:	83 f8 5e             	cmp    $0x5e,%eax
  800607:	76 c6                	jbe    8005cf <vprintfmt+0x1d7>
					putch('?', putdat);
  800609:	83 ec 08             	sub    $0x8,%esp
  80060c:	53                   	push   %ebx
  80060d:	6a 3f                	push   $0x3f
  80060f:	ff d6                	call   *%esi
  800611:	83 c4 10             	add    $0x10,%esp
  800614:	eb c3                	jmp    8005d9 <vprintfmt+0x1e1>
  800616:	89 cf                	mov    %ecx,%edi
  800618:	eb 0e                	jmp    800628 <vprintfmt+0x230>
				putch(' ', putdat);
  80061a:	83 ec 08             	sub    $0x8,%esp
  80061d:	53                   	push   %ebx
  80061e:	6a 20                	push   $0x20
  800620:	ff d6                	call   *%esi
			for (; width > 0; width--)
  800622:	83 ef 01             	sub    $0x1,%edi
  800625:	83 c4 10             	add    $0x10,%esp
  800628:	85 ff                	test   %edi,%edi
  80062a:	7f ee                	jg     80061a <vprintfmt+0x222>
			if ((p = va_arg(ap, char *)) == NULL)
  80062c:	8b 45 c8             	mov    -0x38(%ebp),%eax
  80062f:	89 45 14             	mov    %eax,0x14(%ebp)
  800632:	e9 36 01 00 00       	jmp    80076d <vprintfmt+0x375>
  800637:	89 cf                	mov    %ecx,%edi
  800639:	eb ed                	jmp    800628 <vprintfmt+0x230>
	if (lflag >= 2)
  80063b:	83 f9 01             	cmp    $0x1,%ecx
  80063e:	7f 1f                	jg     80065f <vprintfmt+0x267>
	else if (lflag)
  800640:	85 c9                	test   %ecx,%ecx
  800642:	74 67                	je     8006ab <vprintfmt+0x2b3>
		return va_arg(*ap, long);
  800644:	8b 45 14             	mov    0x14(%ebp),%eax
  800647:	8b 00                	mov    (%eax),%eax
  800649:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80064c:	89 c1                	mov    %eax,%ecx
  80064e:	c1 f9 1f             	sar    $0x1f,%ecx
  800651:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800654:	8b 45 14             	mov    0x14(%ebp),%eax
  800657:	8d 40 04             	lea    0x4(%eax),%eax
  80065a:	89 45 14             	mov    %eax,0x14(%ebp)
  80065d:	eb 17                	jmp    800676 <vprintfmt+0x27e>
		return va_arg(*ap, long long);
  80065f:	8b 45 14             	mov    0x14(%ebp),%eax
  800662:	8b 50 04             	mov    0x4(%eax),%edx
  800665:	8b 00                	mov    (%eax),%eax
  800667:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80066a:	89 55 dc             	mov    %edx,-0x24(%ebp)
  80066d:	8b 45 14             	mov    0x14(%ebp),%eax
  800670:	8d 40 08             	lea    0x8(%eax),%eax
  800673:	89 45 14             	mov    %eax,0x14(%ebp)
			if ((long long) num < 0) {
  800676:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800679:	8b 4d dc             	mov    -0x24(%ebp),%ecx
			base = 10;
  80067c:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800681:	85 c9                	test   %ecx,%ecx
  800683:	0f 89 ca 00 00 00    	jns    800753 <vprintfmt+0x35b>
				putch('-', putdat);
  800689:	83 ec 08             	sub    $0x8,%esp
  80068c:	53                   	push   %ebx
  80068d:	6a 2d                	push   $0x2d
  80068f:	ff d6                	call   *%esi
				num = -(long long) num;
  800691:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800694:	8b 4d dc             	mov    -0x24(%ebp),%ecx
  800697:	f7 da                	neg    %edx
  800699:	83 d1 00             	adc    $0x0,%ecx
  80069c:	f7 d9                	neg    %ecx
  80069e:	83 c4 10             	add    $0x10,%esp
			base = 10;
  8006a1:	b8 0a 00 00 00       	mov    $0xa,%eax
  8006a6:	e9 a8 00 00 00       	jmp    800753 <vprintfmt+0x35b>
		return va_arg(*ap, int);
  8006ab:	8b 45 14             	mov    0x14(%ebp),%eax
  8006ae:	8b 00                	mov    (%eax),%eax
  8006b0:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8006b3:	99                   	cltd   
  8006b4:	89 55 dc             	mov    %edx,-0x24(%ebp)
  8006b7:	8b 45 14             	mov    0x14(%ebp),%eax
  8006ba:	8d 40 04             	lea    0x4(%eax),%eax
  8006bd:	89 45 14             	mov    %eax,0x14(%ebp)
  8006c0:	eb b4                	jmp    800676 <vprintfmt+0x27e>
	if (lflag >= 2)
  8006c2:	83 f9 01             	cmp    $0x1,%ecx
  8006c5:	7f 1b                	jg     8006e2 <vprintfmt+0x2ea>
	else if (lflag)
  8006c7:	85 c9                	test   %ecx,%ecx
  8006c9:	74 2c                	je     8006f7 <vprintfmt+0x2ff>
		return va_arg(*ap, unsigned long);
  8006cb:	8b 45 14             	mov    0x14(%ebp),%eax
  8006ce:	8b 10                	mov    (%eax),%edx
  8006d0:	b9 00 00 00 00       	mov    $0x0,%ecx
  8006d5:	8d 40 04             	lea    0x4(%eax),%eax
  8006d8:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  8006db:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long);
  8006e0:	eb 71                	jmp    800753 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  8006e2:	8b 45 14             	mov    0x14(%ebp),%eax
  8006e5:	8b 10                	mov    (%eax),%edx
  8006e7:	8b 48 04             	mov    0x4(%eax),%ecx
  8006ea:	8d 40 08             	lea    0x8(%eax),%eax
  8006ed:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  8006f0:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned long long);
  8006f5:	eb 5c                	jmp    800753 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  8006f7:	8b 45 14             	mov    0x14(%ebp),%eax
  8006fa:	8b 10                	mov    (%eax),%edx
  8006fc:	b9 00 00 00 00       	mov    $0x0,%ecx
  800701:	8d 40 04             	lea    0x4(%eax),%eax
  800704:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 10;
  800707:	b8 0a 00 00 00       	mov    $0xa,%eax
		return va_arg(*ap, unsigned int);
  80070c:	eb 45                	jmp    800753 <vprintfmt+0x35b>
			putch('X', putdat);
  80070e:	83 ec 08             	sub    $0x8,%esp
  800711:	53                   	push   %ebx
  800712:	6a 58                	push   $0x58
  800714:	ff d6                	call   *%esi
			putch('X', putdat);
  800716:	83 c4 08             	add    $0x8,%esp
  800719:	53                   	push   %ebx
  80071a:	6a 58                	push   $0x58
  80071c:	ff d6                	call   *%esi
			putch('X', putdat);
  80071e:	83 c4 08             	add    $0x8,%esp
  800721:	53                   	push   %ebx
  800722:	6a 58                	push   $0x58
  800724:	ff d6                	call   *%esi
			break;
  800726:	83 c4 10             	add    $0x10,%esp
  800729:	eb 42                	jmp    80076d <vprintfmt+0x375>
			putch('0', putdat);
  80072b:	83 ec 08             	sub    $0x8,%esp
  80072e:	53                   	push   %ebx
  80072f:	6a 30                	push   $0x30
  800731:	ff d6                	call   *%esi
			putch('x', putdat);
  800733:	83 c4 08             	add    $0x8,%esp
  800736:	53                   	push   %ebx
  800737:	6a 78                	push   $0x78
  800739:	ff d6                	call   *%esi
			num = (unsigned long long)
  80073b:	8b 45 14             	mov    0x14(%ebp),%eax
  80073e:	8b 10                	mov    (%eax),%edx
  800740:	b9 00 00 00 00       	mov    $0x0,%ecx
			goto number;
  800745:	83 c4 10             	add    $0x10,%esp
				(uintptr_t) va_arg(ap, void *);
  800748:	8d 40 04             	lea    0x4(%eax),%eax
  80074b:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  80074e:	b8 10 00 00 00       	mov    $0x10,%eax
			printnum(putch, putdat, num, base, width, padc);
  800753:	83 ec 0c             	sub    $0xc,%esp
  800756:	0f be 7d d3          	movsbl -0x2d(%ebp),%edi
  80075a:	57                   	push   %edi
  80075b:	ff 75 d4             	pushl  -0x2c(%ebp)
  80075e:	50                   	push   %eax
  80075f:	51                   	push   %ecx
  800760:	52                   	push   %edx
  800761:	89 da                	mov    %ebx,%edx
  800763:	89 f0                	mov    %esi,%eax
  800765:	e8 a3 fb ff ff       	call   80030d <printnum>
			break;
  80076a:	83 c4 20             	add    $0x20,%esp
			if ((p = va_arg(ap, char *)) == NULL)
  80076d:	8b 7d e4             	mov    -0x1c(%ebp),%edi
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800770:	83 c7 01             	add    $0x1,%edi
  800773:	0f b6 47 ff          	movzbl -0x1(%edi),%eax
  800777:	83 f8 25             	cmp    $0x25,%eax
  80077a:	0f 84 93 fc ff ff    	je     800413 <vprintfmt+0x1b>
			if (ch == '\0')
  800780:	85 c0                	test   %eax,%eax
  800782:	0f 84 8b 00 00 00    	je     800813 <vprintfmt+0x41b>
			putch(ch, putdat);
  800788:	83 ec 08             	sub    $0x8,%esp
  80078b:	53                   	push   %ebx
  80078c:	50                   	push   %eax
  80078d:	ff d6                	call   *%esi
  80078f:	83 c4 10             	add    $0x10,%esp
  800792:	eb dc                	jmp    800770 <vprintfmt+0x378>
	if (lflag >= 2)
  800794:	83 f9 01             	cmp    $0x1,%ecx
  800797:	7f 1b                	jg     8007b4 <vprintfmt+0x3bc>
	else if (lflag)
  800799:	85 c9                	test   %ecx,%ecx
  80079b:	74 2c                	je     8007c9 <vprintfmt+0x3d1>
		return va_arg(*ap, unsigned long);
  80079d:	8b 45 14             	mov    0x14(%ebp),%eax
  8007a0:	8b 10                	mov    (%eax),%edx
  8007a2:	b9 00 00 00 00       	mov    $0x0,%ecx
  8007a7:	8d 40 04             	lea    0x4(%eax),%eax
  8007aa:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  8007ad:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long);
  8007b2:	eb 9f                	jmp    800753 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned long long);
  8007b4:	8b 45 14             	mov    0x14(%ebp),%eax
  8007b7:	8b 10                	mov    (%eax),%edx
  8007b9:	8b 48 04             	mov    0x4(%eax),%ecx
  8007bc:	8d 40 08             	lea    0x8(%eax),%eax
  8007bf:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  8007c2:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned long long);
  8007c7:	eb 8a                	jmp    800753 <vprintfmt+0x35b>
		return va_arg(*ap, unsigned int);
  8007c9:	8b 45 14             	mov    0x14(%ebp),%eax
  8007cc:	8b 10                	mov    (%eax),%edx
  8007ce:	b9 00 00 00 00       	mov    $0x0,%ecx
  8007d3:	8d 40 04             	lea    0x4(%eax),%eax
  8007d6:	89 45 14             	mov    %eax,0x14(%ebp)
			base = 16;
  8007d9:	b8 10 00 00 00       	mov    $0x10,%eax
		return va_arg(*ap, unsigned int);
  8007de:	e9 70 ff ff ff       	jmp    800753 <vprintfmt+0x35b>
			putch(ch, putdat);
  8007e3:	83 ec 08             	sub    $0x8,%esp
  8007e6:	53                   	push   %ebx
  8007e7:	6a 25                	push   $0x25
  8007e9:	ff d6                	call   *%esi
			break;
  8007eb:	83 c4 10             	add    $0x10,%esp
  8007ee:	e9 7a ff ff ff       	jmp    80076d <vprintfmt+0x375>
			putch('%', putdat);
  8007f3:	83 ec 08             	sub    $0x8,%esp
  8007f6:	53                   	push   %ebx
  8007f7:	6a 25                	push   $0x25
  8007f9:	ff d6                	call   *%esi
			for (fmt--; fmt[-1] != '%'; fmt--)
  8007fb:	83 c4 10             	add    $0x10,%esp
  8007fe:	89 f8                	mov    %edi,%eax
  800800:	80 78 ff 25          	cmpb   $0x25,-0x1(%eax)
  800804:	74 05                	je     80080b <vprintfmt+0x413>
  800806:	83 e8 01             	sub    $0x1,%eax
  800809:	eb f5                	jmp    800800 <vprintfmt+0x408>
  80080b:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80080e:	e9 5a ff ff ff       	jmp    80076d <vprintfmt+0x375>
}
  800813:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800816:	5b                   	pop    %ebx
  800817:	5e                   	pop    %esi
  800818:	5f                   	pop    %edi
  800819:	5d                   	pop    %ebp
  80081a:	c3                   	ret    

0080081b <vsnprintf>:

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  80081b:	f3 0f 1e fb          	endbr32 
  80081f:	55                   	push   %ebp
  800820:	89 e5                	mov    %esp,%ebp
  800822:	83 ec 18             	sub    $0x18,%esp
  800825:	8b 45 08             	mov    0x8(%ebp),%eax
  800828:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};
  80082b:	89 45 ec             	mov    %eax,-0x14(%ebp)
  80082e:	8d 4c 10 ff          	lea    -0x1(%eax,%edx,1),%ecx
  800832:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  800835:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
  80083c:	85 c0                	test   %eax,%eax
  80083e:	74 26                	je     800866 <vsnprintf+0x4b>
  800840:	85 d2                	test   %edx,%edx
  800842:	7e 22                	jle    800866 <vsnprintf+0x4b>
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  800844:	ff 75 14             	pushl  0x14(%ebp)
  800847:	ff 75 10             	pushl  0x10(%ebp)
  80084a:	8d 45 ec             	lea    -0x14(%ebp),%eax
  80084d:	50                   	push   %eax
  80084e:	68 b6 03 80 00       	push   $0x8003b6
  800853:	e8 a0 fb ff ff       	call   8003f8 <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800858:	8b 45 ec             	mov    -0x14(%ebp),%eax
  80085b:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  80085e:	8b 45 f4             	mov    -0xc(%ebp),%eax
  800861:	83 c4 10             	add    $0x10,%esp
}
  800864:	c9                   	leave  
  800865:	c3                   	ret    
		return -E_INVAL;
  800866:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80086b:	eb f7                	jmp    800864 <vsnprintf+0x49>

0080086d <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  80086d:	f3 0f 1e fb          	endbr32 
  800871:	55                   	push   %ebp
  800872:	89 e5                	mov    %esp,%ebp
  800874:	83 ec 08             	sub    $0x8,%esp
	va_list ap;
	int rc;

	va_start(ap, fmt);
  800877:	8d 45 14             	lea    0x14(%ebp),%eax
	rc = vsnprintf(buf, n, fmt, ap);
  80087a:	50                   	push   %eax
  80087b:	ff 75 10             	pushl  0x10(%ebp)
  80087e:	ff 75 0c             	pushl  0xc(%ebp)
  800881:	ff 75 08             	pushl  0x8(%ebp)
  800884:	e8 92 ff ff ff       	call   80081b <vsnprintf>
	va_end(ap);

	return rc;
}
  800889:	c9                   	leave  
  80088a:	c3                   	ret    

0080088b <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  80088b:	f3 0f 1e fb          	endbr32 
  80088f:	55                   	push   %ebp
  800890:	89 e5                	mov    %esp,%ebp
  800892:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800895:	b8 00 00 00 00       	mov    $0x0,%eax
  80089a:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  80089e:	74 05                	je     8008a5 <strlen+0x1a>
		n++;
  8008a0:	83 c0 01             	add    $0x1,%eax
  8008a3:	eb f5                	jmp    80089a <strlen+0xf>
	return n;
}
  8008a5:	5d                   	pop    %ebp
  8008a6:	c3                   	ret    

008008a7 <strnlen>:

int
strnlen(const char *s, size_t size)
{
  8008a7:	f3 0f 1e fb          	endbr32 
  8008ab:	55                   	push   %ebp
  8008ac:	89 e5                	mov    %esp,%ebp
  8008ae:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8008b1:	8b 55 0c             	mov    0xc(%ebp),%edx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  8008b4:	b8 00 00 00 00       	mov    $0x0,%eax
  8008b9:	39 d0                	cmp    %edx,%eax
  8008bb:	74 0d                	je     8008ca <strnlen+0x23>
  8008bd:	80 3c 01 00          	cmpb   $0x0,(%ecx,%eax,1)
  8008c1:	74 05                	je     8008c8 <strnlen+0x21>
		n++;
  8008c3:	83 c0 01             	add    $0x1,%eax
  8008c6:	eb f1                	jmp    8008b9 <strnlen+0x12>
  8008c8:	89 c2                	mov    %eax,%edx
	return n;
}
  8008ca:	89 d0                	mov    %edx,%eax
  8008cc:	5d                   	pop    %ebp
  8008cd:	c3                   	ret    

008008ce <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  8008ce:	f3 0f 1e fb          	endbr32 
  8008d2:	55                   	push   %ebp
  8008d3:	89 e5                	mov    %esp,%ebp
  8008d5:	53                   	push   %ebx
  8008d6:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8008d9:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  8008dc:	b8 00 00 00 00       	mov    $0x0,%eax
  8008e1:	0f b6 14 03          	movzbl (%ebx,%eax,1),%edx
  8008e5:	88 14 01             	mov    %dl,(%ecx,%eax,1)
  8008e8:	83 c0 01             	add    $0x1,%eax
  8008eb:	84 d2                	test   %dl,%dl
  8008ed:	75 f2                	jne    8008e1 <strcpy+0x13>
		/* do nothing */;
	return ret;
}
  8008ef:	89 c8                	mov    %ecx,%eax
  8008f1:	5b                   	pop    %ebx
  8008f2:	5d                   	pop    %ebp
  8008f3:	c3                   	ret    

008008f4 <strcat>:

char *
strcat(char *dst, const char *src)
{
  8008f4:	f3 0f 1e fb          	endbr32 
  8008f8:	55                   	push   %ebp
  8008f9:	89 e5                	mov    %esp,%ebp
  8008fb:	53                   	push   %ebx
  8008fc:	83 ec 10             	sub    $0x10,%esp
  8008ff:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int len = strlen(dst);
  800902:	53                   	push   %ebx
  800903:	e8 83 ff ff ff       	call   80088b <strlen>
  800908:	83 c4 08             	add    $0x8,%esp
	strcpy(dst + len, src);
  80090b:	ff 75 0c             	pushl  0xc(%ebp)
  80090e:	01 d8                	add    %ebx,%eax
  800910:	50                   	push   %eax
  800911:	e8 b8 ff ff ff       	call   8008ce <strcpy>
	return dst;
}
  800916:	89 d8                	mov    %ebx,%eax
  800918:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  80091b:	c9                   	leave  
  80091c:	c3                   	ret    

0080091d <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  80091d:	f3 0f 1e fb          	endbr32 
  800921:	55                   	push   %ebp
  800922:	89 e5                	mov    %esp,%ebp
  800924:	56                   	push   %esi
  800925:	53                   	push   %ebx
  800926:	8b 75 08             	mov    0x8(%ebp),%esi
  800929:	8b 55 0c             	mov    0xc(%ebp),%edx
  80092c:	89 f3                	mov    %esi,%ebx
  80092e:	03 5d 10             	add    0x10(%ebp),%ebx
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800931:	89 f0                	mov    %esi,%eax
  800933:	39 d8                	cmp    %ebx,%eax
  800935:	74 11                	je     800948 <strncpy+0x2b>
		*dst++ = *src;
  800937:	83 c0 01             	add    $0x1,%eax
  80093a:	0f b6 0a             	movzbl (%edx),%ecx
  80093d:	88 48 ff             	mov    %cl,-0x1(%eax)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800940:	80 f9 01             	cmp    $0x1,%cl
  800943:	83 da ff             	sbb    $0xffffffff,%edx
  800946:	eb eb                	jmp    800933 <strncpy+0x16>
	}
	return ret;
}
  800948:	89 f0                	mov    %esi,%eax
  80094a:	5b                   	pop    %ebx
  80094b:	5e                   	pop    %esi
  80094c:	5d                   	pop    %ebp
  80094d:	c3                   	ret    

0080094e <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  80094e:	f3 0f 1e fb          	endbr32 
  800952:	55                   	push   %ebp
  800953:	89 e5                	mov    %esp,%ebp
  800955:	56                   	push   %esi
  800956:	53                   	push   %ebx
  800957:	8b 75 08             	mov    0x8(%ebp),%esi
  80095a:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80095d:	8b 55 10             	mov    0x10(%ebp),%edx
  800960:	89 f0                	mov    %esi,%eax
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800962:	85 d2                	test   %edx,%edx
  800964:	74 21                	je     800987 <strlcpy+0x39>
  800966:	8d 44 16 ff          	lea    -0x1(%esi,%edx,1),%eax
  80096a:	89 f2                	mov    %esi,%edx
		while (--size > 0 && *src != '\0')
  80096c:	39 c2                	cmp    %eax,%edx
  80096e:	74 14                	je     800984 <strlcpy+0x36>
  800970:	0f b6 19             	movzbl (%ecx),%ebx
  800973:	84 db                	test   %bl,%bl
  800975:	74 0b                	je     800982 <strlcpy+0x34>
			*dst++ = *src++;
  800977:	83 c1 01             	add    $0x1,%ecx
  80097a:	83 c2 01             	add    $0x1,%edx
  80097d:	88 5a ff             	mov    %bl,-0x1(%edx)
  800980:	eb ea                	jmp    80096c <strlcpy+0x1e>
  800982:	89 d0                	mov    %edx,%eax
		*dst = '\0';
  800984:	c6 00 00             	movb   $0x0,(%eax)
	}
	return dst - dst_in;
  800987:	29 f0                	sub    %esi,%eax
}
  800989:	5b                   	pop    %ebx
  80098a:	5e                   	pop    %esi
  80098b:	5d                   	pop    %ebp
  80098c:	c3                   	ret    

0080098d <strcmp>:

int
strcmp(const char *p, const char *q)
{
  80098d:	f3 0f 1e fb          	endbr32 
  800991:	55                   	push   %ebp
  800992:	89 e5                	mov    %esp,%ebp
  800994:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800997:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  80099a:	0f b6 01             	movzbl (%ecx),%eax
  80099d:	84 c0                	test   %al,%al
  80099f:	74 0c                	je     8009ad <strcmp+0x20>
  8009a1:	3a 02                	cmp    (%edx),%al
  8009a3:	75 08                	jne    8009ad <strcmp+0x20>
		p++, q++;
  8009a5:	83 c1 01             	add    $0x1,%ecx
  8009a8:	83 c2 01             	add    $0x1,%edx
  8009ab:	eb ed                	jmp    80099a <strcmp+0xd>
	return (int) ((unsigned char) *p - (unsigned char) *q);
  8009ad:	0f b6 c0             	movzbl %al,%eax
  8009b0:	0f b6 12             	movzbl (%edx),%edx
  8009b3:	29 d0                	sub    %edx,%eax
}
  8009b5:	5d                   	pop    %ebp
  8009b6:	c3                   	ret    

008009b7 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  8009b7:	f3 0f 1e fb          	endbr32 
  8009bb:	55                   	push   %ebp
  8009bc:	89 e5                	mov    %esp,%ebp
  8009be:	53                   	push   %ebx
  8009bf:	8b 45 08             	mov    0x8(%ebp),%eax
  8009c2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8009c5:	89 c3                	mov    %eax,%ebx
  8009c7:	03 5d 10             	add    0x10(%ebp),%ebx
	while (n > 0 && *p && *p == *q)
  8009ca:	eb 06                	jmp    8009d2 <strncmp+0x1b>
		n--, p++, q++;
  8009cc:	83 c0 01             	add    $0x1,%eax
  8009cf:	83 c2 01             	add    $0x1,%edx
	while (n > 0 && *p && *p == *q)
  8009d2:	39 d8                	cmp    %ebx,%eax
  8009d4:	74 16                	je     8009ec <strncmp+0x35>
  8009d6:	0f b6 08             	movzbl (%eax),%ecx
  8009d9:	84 c9                	test   %cl,%cl
  8009db:	74 04                	je     8009e1 <strncmp+0x2a>
  8009dd:	3a 0a                	cmp    (%edx),%cl
  8009df:	74 eb                	je     8009cc <strncmp+0x15>
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  8009e1:	0f b6 00             	movzbl (%eax),%eax
  8009e4:	0f b6 12             	movzbl (%edx),%edx
  8009e7:	29 d0                	sub    %edx,%eax
}
  8009e9:	5b                   	pop    %ebx
  8009ea:	5d                   	pop    %ebp
  8009eb:	c3                   	ret    
		return 0;
  8009ec:	b8 00 00 00 00       	mov    $0x0,%eax
  8009f1:	eb f6                	jmp    8009e9 <strncmp+0x32>

008009f3 <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  8009f3:	f3 0f 1e fb          	endbr32 
  8009f7:	55                   	push   %ebp
  8009f8:	89 e5                	mov    %esp,%ebp
  8009fa:	8b 45 08             	mov    0x8(%ebp),%eax
  8009fd:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800a01:	0f b6 10             	movzbl (%eax),%edx
  800a04:	84 d2                	test   %dl,%dl
  800a06:	74 09                	je     800a11 <strchr+0x1e>
		if (*s == c)
  800a08:	38 ca                	cmp    %cl,%dl
  800a0a:	74 0a                	je     800a16 <strchr+0x23>
	for (; *s; s++)
  800a0c:	83 c0 01             	add    $0x1,%eax
  800a0f:	eb f0                	jmp    800a01 <strchr+0xe>
			return (char *) s;
	return 0;
  800a11:	b8 00 00 00 00       	mov    $0x0,%eax
}
  800a16:	5d                   	pop    %ebp
  800a17:	c3                   	ret    

00800a18 <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800a18:	f3 0f 1e fb          	endbr32 
  800a1c:	55                   	push   %ebp
  800a1d:	89 e5                	mov    %esp,%ebp
  800a1f:	8b 45 08             	mov    0x8(%ebp),%eax
  800a22:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800a26:	0f b6 10             	movzbl (%eax),%edx
		if (*s == c)
  800a29:	38 ca                	cmp    %cl,%dl
  800a2b:	74 09                	je     800a36 <strfind+0x1e>
  800a2d:	84 d2                	test   %dl,%dl
  800a2f:	74 05                	je     800a36 <strfind+0x1e>
	for (; *s; s++)
  800a31:	83 c0 01             	add    $0x1,%eax
  800a34:	eb f0                	jmp    800a26 <strfind+0xe>
			break;
	return (char *) s;
}
  800a36:	5d                   	pop    %ebp
  800a37:	c3                   	ret    

00800a38 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800a38:	f3 0f 1e fb          	endbr32 
  800a3c:	55                   	push   %ebp
  800a3d:	89 e5                	mov    %esp,%ebp
  800a3f:	57                   	push   %edi
  800a40:	56                   	push   %esi
  800a41:	53                   	push   %ebx
  800a42:	8b 7d 08             	mov    0x8(%ebp),%edi
  800a45:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800a48:	85 c9                	test   %ecx,%ecx
  800a4a:	74 31                	je     800a7d <memset+0x45>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800a4c:	89 f8                	mov    %edi,%eax
  800a4e:	09 c8                	or     %ecx,%eax
  800a50:	a8 03                	test   $0x3,%al
  800a52:	75 23                	jne    800a77 <memset+0x3f>
		c &= 0xFF;
  800a54:	0f b6 55 0c          	movzbl 0xc(%ebp),%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800a58:	89 d3                	mov    %edx,%ebx
  800a5a:	c1 e3 08             	shl    $0x8,%ebx
  800a5d:	89 d0                	mov    %edx,%eax
  800a5f:	c1 e0 18             	shl    $0x18,%eax
  800a62:	89 d6                	mov    %edx,%esi
  800a64:	c1 e6 10             	shl    $0x10,%esi
  800a67:	09 f0                	or     %esi,%eax
  800a69:	09 c2                	or     %eax,%edx
  800a6b:	09 da                	or     %ebx,%edx
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
  800a6d:	c1 e9 02             	shr    $0x2,%ecx
		asm volatile("cld; rep stosl\n"
  800a70:	89 d0                	mov    %edx,%eax
  800a72:	fc                   	cld    
  800a73:	f3 ab                	rep stos %eax,%es:(%edi)
  800a75:	eb 06                	jmp    800a7d <memset+0x45>
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800a77:	8b 45 0c             	mov    0xc(%ebp),%eax
  800a7a:	fc                   	cld    
  800a7b:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800a7d:	89 f8                	mov    %edi,%eax
  800a7f:	5b                   	pop    %ebx
  800a80:	5e                   	pop    %esi
  800a81:	5f                   	pop    %edi
  800a82:	5d                   	pop    %ebp
  800a83:	c3                   	ret    

00800a84 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800a84:	f3 0f 1e fb          	endbr32 
  800a88:	55                   	push   %ebp
  800a89:	89 e5                	mov    %esp,%ebp
  800a8b:	57                   	push   %edi
  800a8c:	56                   	push   %esi
  800a8d:	8b 45 08             	mov    0x8(%ebp),%eax
  800a90:	8b 75 0c             	mov    0xc(%ebp),%esi
  800a93:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;

	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800a96:	39 c6                	cmp    %eax,%esi
  800a98:	73 32                	jae    800acc <memmove+0x48>
  800a9a:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800a9d:	39 c2                	cmp    %eax,%edx
  800a9f:	76 2b                	jbe    800acc <memmove+0x48>
		s += n;
		d += n;
  800aa1:	8d 3c 08             	lea    (%eax,%ecx,1),%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800aa4:	89 fe                	mov    %edi,%esi
  800aa6:	09 ce                	or     %ecx,%esi
  800aa8:	09 d6                	or     %edx,%esi
  800aaa:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800ab0:	75 0e                	jne    800ac0 <memmove+0x3c>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
  800ab2:	83 ef 04             	sub    $0x4,%edi
  800ab5:	8d 72 fc             	lea    -0x4(%edx),%esi
  800ab8:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("std; rep movsl\n"
  800abb:	fd                   	std    
  800abc:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  800abe:	eb 09                	jmp    800ac9 <memmove+0x45>
		else
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
  800ac0:	83 ef 01             	sub    $0x1,%edi
  800ac3:	8d 72 ff             	lea    -0x1(%edx),%esi
			asm volatile("std; rep movsb\n"
  800ac6:	fd                   	std    
  800ac7:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800ac9:	fc                   	cld    
  800aca:	eb 1a                	jmp    800ae6 <memmove+0x62>
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800acc:	89 c2                	mov    %eax,%edx
  800ace:	09 ca                	or     %ecx,%edx
  800ad0:	09 f2                	or     %esi,%edx
  800ad2:	f6 c2 03             	test   $0x3,%dl
  800ad5:	75 0a                	jne    800ae1 <memmove+0x5d>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
  800ad7:	c1 e9 02             	shr    $0x2,%ecx
			asm volatile("cld; rep movsl\n"
  800ada:	89 c7                	mov    %eax,%edi
  800adc:	fc                   	cld    
  800add:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
  800adf:	eb 05                	jmp    800ae6 <memmove+0x62>
		else
			asm volatile("cld; rep movsb\n"
  800ae1:	89 c7                	mov    %eax,%edi
  800ae3:	fc                   	cld    
  800ae4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800ae6:	5e                   	pop    %esi
  800ae7:	5f                   	pop    %edi
  800ae8:	5d                   	pop    %ebp
  800ae9:	c3                   	ret    

00800aea <memcpy>:
}
#endif

void *
memcpy(void *dst, const void *src, size_t n)
{
  800aea:	f3 0f 1e fb          	endbr32 
  800aee:	55                   	push   %ebp
  800aef:	89 e5                	mov    %esp,%ebp
  800af1:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800af4:	ff 75 10             	pushl  0x10(%ebp)
  800af7:	ff 75 0c             	pushl  0xc(%ebp)
  800afa:	ff 75 08             	pushl  0x8(%ebp)
  800afd:	e8 82 ff ff ff       	call   800a84 <memmove>
}
  800b02:	c9                   	leave  
  800b03:	c3                   	ret    

00800b04 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800b04:	f3 0f 1e fb          	endbr32 
  800b08:	55                   	push   %ebp
  800b09:	89 e5                	mov    %esp,%ebp
  800b0b:	56                   	push   %esi
  800b0c:	53                   	push   %ebx
  800b0d:	8b 45 08             	mov    0x8(%ebp),%eax
  800b10:	8b 55 0c             	mov    0xc(%ebp),%edx
  800b13:	89 c6                	mov    %eax,%esi
  800b15:	03 75 10             	add    0x10(%ebp),%esi
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800b18:	39 f0                	cmp    %esi,%eax
  800b1a:	74 1c                	je     800b38 <memcmp+0x34>
		if (*s1 != *s2)
  800b1c:	0f b6 08             	movzbl (%eax),%ecx
  800b1f:	0f b6 1a             	movzbl (%edx),%ebx
  800b22:	38 d9                	cmp    %bl,%cl
  800b24:	75 08                	jne    800b2e <memcmp+0x2a>
			return (int) *s1 - (int) *s2;
		s1++, s2++;
  800b26:	83 c0 01             	add    $0x1,%eax
  800b29:	83 c2 01             	add    $0x1,%edx
  800b2c:	eb ea                	jmp    800b18 <memcmp+0x14>
			return (int) *s1 - (int) *s2;
  800b2e:	0f b6 c1             	movzbl %cl,%eax
  800b31:	0f b6 db             	movzbl %bl,%ebx
  800b34:	29 d8                	sub    %ebx,%eax
  800b36:	eb 05                	jmp    800b3d <memcmp+0x39>
	}

	return 0;
  800b38:	b8 00 00 00 00       	mov    $0x0,%eax
}
  800b3d:	5b                   	pop    %ebx
  800b3e:	5e                   	pop    %esi
  800b3f:	5d                   	pop    %ebp
  800b40:	c3                   	ret    

00800b41 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800b41:	f3 0f 1e fb          	endbr32 
  800b45:	55                   	push   %ebp
  800b46:	89 e5                	mov    %esp,%ebp
  800b48:	8b 45 08             	mov    0x8(%ebp),%eax
  800b4b:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	const void *ends = (const char *) s + n;
  800b4e:	89 c2                	mov    %eax,%edx
  800b50:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800b53:	39 d0                	cmp    %edx,%eax
  800b55:	73 09                	jae    800b60 <memfind+0x1f>
		if (*(const unsigned char *) s == (unsigned char) c)
  800b57:	38 08                	cmp    %cl,(%eax)
  800b59:	74 05                	je     800b60 <memfind+0x1f>
	for (; s < ends; s++)
  800b5b:	83 c0 01             	add    $0x1,%eax
  800b5e:	eb f3                	jmp    800b53 <memfind+0x12>
			break;
	return (void *) s;
}
  800b60:	5d                   	pop    %ebp
  800b61:	c3                   	ret    

00800b62 <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800b62:	f3 0f 1e fb          	endbr32 
  800b66:	55                   	push   %ebp
  800b67:	89 e5                	mov    %esp,%ebp
  800b69:	57                   	push   %edi
  800b6a:	56                   	push   %esi
  800b6b:	53                   	push   %ebx
  800b6c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800b6f:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800b72:	eb 03                	jmp    800b77 <strtol+0x15>
		s++;
  800b74:	83 c1 01             	add    $0x1,%ecx
	while (*s == ' ' || *s == '\t')
  800b77:	0f b6 01             	movzbl (%ecx),%eax
  800b7a:	3c 20                	cmp    $0x20,%al
  800b7c:	74 f6                	je     800b74 <strtol+0x12>
  800b7e:	3c 09                	cmp    $0x9,%al
  800b80:	74 f2                	je     800b74 <strtol+0x12>

	// plus/minus sign
	if (*s == '+')
  800b82:	3c 2b                	cmp    $0x2b,%al
  800b84:	74 2a                	je     800bb0 <strtol+0x4e>
	int neg = 0;
  800b86:	bf 00 00 00 00       	mov    $0x0,%edi
		s++;
	else if (*s == '-')
  800b8b:	3c 2d                	cmp    $0x2d,%al
  800b8d:	74 2b                	je     800bba <strtol+0x58>
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800b8f:	f7 c3 ef ff ff ff    	test   $0xffffffef,%ebx
  800b95:	75 0f                	jne    800ba6 <strtol+0x44>
  800b97:	80 39 30             	cmpb   $0x30,(%ecx)
  800b9a:	74 28                	je     800bc4 <strtol+0x62>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
		s++, base = 8;
	else if (base == 0)
		base = 10;
  800b9c:	85 db                	test   %ebx,%ebx
  800b9e:	b8 0a 00 00 00       	mov    $0xa,%eax
  800ba3:	0f 44 d8             	cmove  %eax,%ebx
  800ba6:	b8 00 00 00 00       	mov    $0x0,%eax
  800bab:	89 5d 10             	mov    %ebx,0x10(%ebp)
  800bae:	eb 46                	jmp    800bf6 <strtol+0x94>
		s++;
  800bb0:	83 c1 01             	add    $0x1,%ecx
	int neg = 0;
  800bb3:	bf 00 00 00 00       	mov    $0x0,%edi
  800bb8:	eb d5                	jmp    800b8f <strtol+0x2d>
		s++, neg = 1;
  800bba:	83 c1 01             	add    $0x1,%ecx
  800bbd:	bf 01 00 00 00       	mov    $0x1,%edi
  800bc2:	eb cb                	jmp    800b8f <strtol+0x2d>
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800bc4:	80 79 01 78          	cmpb   $0x78,0x1(%ecx)
  800bc8:	74 0e                	je     800bd8 <strtol+0x76>
	else if (base == 0 && s[0] == '0')
  800bca:	85 db                	test   %ebx,%ebx
  800bcc:	75 d8                	jne    800ba6 <strtol+0x44>
		s++, base = 8;
  800bce:	83 c1 01             	add    $0x1,%ecx
  800bd1:	bb 08 00 00 00       	mov    $0x8,%ebx
  800bd6:	eb ce                	jmp    800ba6 <strtol+0x44>
		s += 2, base = 16;
  800bd8:	83 c1 02             	add    $0x2,%ecx
  800bdb:	bb 10 00 00 00       	mov    $0x10,%ebx
  800be0:	eb c4                	jmp    800ba6 <strtol+0x44>
	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
			dig = *s - '0';
  800be2:	0f be d2             	movsbl %dl,%edx
  800be5:	83 ea 30             	sub    $0x30,%edx
			dig = *s - 'a' + 10;
		else if (*s >= 'A' && *s <= 'Z')
			dig = *s - 'A' + 10;
		else
			break;
		if (dig >= base)
  800be8:	3b 55 10             	cmp    0x10(%ebp),%edx
  800beb:	7d 3a                	jge    800c27 <strtol+0xc5>
			break;
		s++, val = (val * base) + dig;
  800bed:	83 c1 01             	add    $0x1,%ecx
  800bf0:	0f af 45 10          	imul   0x10(%ebp),%eax
  800bf4:	01 d0                	add    %edx,%eax
		if (*s >= '0' && *s <= '9')
  800bf6:	0f b6 11             	movzbl (%ecx),%edx
  800bf9:	8d 72 d0             	lea    -0x30(%edx),%esi
  800bfc:	89 f3                	mov    %esi,%ebx
  800bfe:	80 fb 09             	cmp    $0x9,%bl
  800c01:	76 df                	jbe    800be2 <strtol+0x80>
		else if (*s >= 'a' && *s <= 'z')
  800c03:	8d 72 9f             	lea    -0x61(%edx),%esi
  800c06:	89 f3                	mov    %esi,%ebx
  800c08:	80 fb 19             	cmp    $0x19,%bl
  800c0b:	77 08                	ja     800c15 <strtol+0xb3>
			dig = *s - 'a' + 10;
  800c0d:	0f be d2             	movsbl %dl,%edx
  800c10:	83 ea 57             	sub    $0x57,%edx
  800c13:	eb d3                	jmp    800be8 <strtol+0x86>
		else if (*s >= 'A' && *s <= 'Z')
  800c15:	8d 72 bf             	lea    -0x41(%edx),%esi
  800c18:	89 f3                	mov    %esi,%ebx
  800c1a:	80 fb 19             	cmp    $0x19,%bl
  800c1d:	77 08                	ja     800c27 <strtol+0xc5>
			dig = *s - 'A' + 10;
  800c1f:	0f be d2             	movsbl %dl,%edx
  800c22:	83 ea 37             	sub    $0x37,%edx
  800c25:	eb c1                	jmp    800be8 <strtol+0x86>
		// we don't properly detect overflow!
	}

	if (endptr)
  800c27:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800c2b:	74 05                	je     800c32 <strtol+0xd0>
		*endptr = (char *) s;
  800c2d:	8b 75 0c             	mov    0xc(%ebp),%esi
  800c30:	89 0e                	mov    %ecx,(%esi)
	return (neg ? -val : val);
  800c32:	89 c2                	mov    %eax,%edx
  800c34:	f7 da                	neg    %edx
  800c36:	85 ff                	test   %edi,%edi
  800c38:	0f 45 c2             	cmovne %edx,%eax
}
  800c3b:	5b                   	pop    %ebx
  800c3c:	5e                   	pop    %esi
  800c3d:	5f                   	pop    %edi
  800c3e:	5d                   	pop    %ebp
  800c3f:	c3                   	ret    

00800c40 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800c40:	f3 0f 1e fb          	endbr32 
  800c44:	55                   	push   %ebp
  800c45:	89 e5                	mov    %esp,%ebp
  800c47:	57                   	push   %edi
  800c48:	56                   	push   %esi
  800c49:	53                   	push   %ebx
	asm volatile("int %1\n"
  800c4a:	b8 00 00 00 00       	mov    $0x0,%eax
  800c4f:	8b 55 08             	mov    0x8(%ebp),%edx
  800c52:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800c55:	89 c3                	mov    %eax,%ebx
  800c57:	89 c7                	mov    %eax,%edi
  800c59:	89 c6                	mov    %eax,%esi
  800c5b:	cd 30                	int    $0x30
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800c5d:	5b                   	pop    %ebx
  800c5e:	5e                   	pop    %esi
  800c5f:	5f                   	pop    %edi
  800c60:	5d                   	pop    %ebp
  800c61:	c3                   	ret    

00800c62 <sys_cgetc>:

int
sys_cgetc(void)
{
  800c62:	f3 0f 1e fb          	endbr32 
  800c66:	55                   	push   %ebp
  800c67:	89 e5                	mov    %esp,%ebp
  800c69:	57                   	push   %edi
  800c6a:	56                   	push   %esi
  800c6b:	53                   	push   %ebx
	asm volatile("int %1\n"
  800c6c:	ba 00 00 00 00       	mov    $0x0,%edx
  800c71:	b8 01 00 00 00       	mov    $0x1,%eax
  800c76:	89 d1                	mov    %edx,%ecx
  800c78:	89 d3                	mov    %edx,%ebx
  800c7a:	89 d7                	mov    %edx,%edi
  800c7c:	89 d6                	mov    %edx,%esi
  800c7e:	cd 30                	int    $0x30
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800c80:	5b                   	pop    %ebx
  800c81:	5e                   	pop    %esi
  800c82:	5f                   	pop    %edi
  800c83:	5d                   	pop    %ebp
  800c84:	c3                   	ret    

00800c85 <sys_env_destroy>:

int
sys_env_destroy(envid_t envid)
{
  800c85:	f3 0f 1e fb          	endbr32 
  800c89:	55                   	push   %ebp
  800c8a:	89 e5                	mov    %esp,%ebp
  800c8c:	57                   	push   %edi
  800c8d:	56                   	push   %esi
  800c8e:	53                   	push   %ebx
  800c8f:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800c92:	b9 00 00 00 00       	mov    $0x0,%ecx
  800c97:	8b 55 08             	mov    0x8(%ebp),%edx
  800c9a:	b8 03 00 00 00       	mov    $0x3,%eax
  800c9f:	89 cb                	mov    %ecx,%ebx
  800ca1:	89 cf                	mov    %ecx,%edi
  800ca3:	89 ce                	mov    %ecx,%esi
  800ca5:	cd 30                	int    $0x30
	if(check && ret > 0)
  800ca7:	85 c0                	test   %eax,%eax
  800ca9:	7f 08                	jg     800cb3 <sys_env_destroy+0x2e>
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  800cab:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800cae:	5b                   	pop    %ebx
  800caf:	5e                   	pop    %esi
  800cb0:	5f                   	pop    %edi
  800cb1:	5d                   	pop    %ebp
  800cb2:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800cb3:	83 ec 0c             	sub    $0xc,%esp
  800cb6:	50                   	push   %eax
  800cb7:	6a 03                	push   $0x3
  800cb9:	68 3f 2e 80 00       	push   $0x802e3f
  800cbe:	6a 23                	push   $0x23
  800cc0:	68 5c 2e 80 00       	push   $0x802e5c
  800cc5:	e8 44 f5 ff ff       	call   80020e <_panic>

00800cca <sys_getenvid>:

envid_t
sys_getenvid(void)
{
  800cca:	f3 0f 1e fb          	endbr32 
  800cce:	55                   	push   %ebp
  800ccf:	89 e5                	mov    %esp,%ebp
  800cd1:	57                   	push   %edi
  800cd2:	56                   	push   %esi
  800cd3:	53                   	push   %ebx
	asm volatile("int %1\n"
  800cd4:	ba 00 00 00 00       	mov    $0x0,%edx
  800cd9:	b8 02 00 00 00       	mov    $0x2,%eax
  800cde:	89 d1                	mov    %edx,%ecx
  800ce0:	89 d3                	mov    %edx,%ebx
  800ce2:	89 d7                	mov    %edx,%edi
  800ce4:	89 d6                	mov    %edx,%esi
  800ce6:	cd 30                	int    $0x30
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  800ce8:	5b                   	pop    %ebx
  800ce9:	5e                   	pop    %esi
  800cea:	5f                   	pop    %edi
  800ceb:	5d                   	pop    %ebp
  800cec:	c3                   	ret    

00800ced <sys_yield>:

void
sys_yield(void)
{
  800ced:	f3 0f 1e fb          	endbr32 
  800cf1:	55                   	push   %ebp
  800cf2:	89 e5                	mov    %esp,%ebp
  800cf4:	57                   	push   %edi
  800cf5:	56                   	push   %esi
  800cf6:	53                   	push   %ebx
	asm volatile("int %1\n"
  800cf7:	ba 00 00 00 00       	mov    $0x0,%edx
  800cfc:	b8 0b 00 00 00       	mov    $0xb,%eax
  800d01:	89 d1                	mov    %edx,%ecx
  800d03:	89 d3                	mov    %edx,%ebx
  800d05:	89 d7                	mov    %edx,%edi
  800d07:	89 d6                	mov    %edx,%esi
  800d09:	cd 30                	int    $0x30
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  800d0b:	5b                   	pop    %ebx
  800d0c:	5e                   	pop    %esi
  800d0d:	5f                   	pop    %edi
  800d0e:	5d                   	pop    %ebp
  800d0f:	c3                   	ret    

00800d10 <sys_page_alloc>:

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  800d10:	f3 0f 1e fb          	endbr32 
  800d14:	55                   	push   %ebp
  800d15:	89 e5                	mov    %esp,%ebp
  800d17:	57                   	push   %edi
  800d18:	56                   	push   %esi
  800d19:	53                   	push   %ebx
  800d1a:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800d1d:	be 00 00 00 00       	mov    $0x0,%esi
  800d22:	8b 55 08             	mov    0x8(%ebp),%edx
  800d25:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800d28:	b8 04 00 00 00       	mov    $0x4,%eax
  800d2d:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800d30:	89 f7                	mov    %esi,%edi
  800d32:	cd 30                	int    $0x30
	if(check && ret > 0)
  800d34:	85 c0                	test   %eax,%eax
  800d36:	7f 08                	jg     800d40 <sys_page_alloc+0x30>
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  800d38:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800d3b:	5b                   	pop    %ebx
  800d3c:	5e                   	pop    %esi
  800d3d:	5f                   	pop    %edi
  800d3e:	5d                   	pop    %ebp
  800d3f:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800d40:	83 ec 0c             	sub    $0xc,%esp
  800d43:	50                   	push   %eax
  800d44:	6a 04                	push   $0x4
  800d46:	68 3f 2e 80 00       	push   $0x802e3f
  800d4b:	6a 23                	push   $0x23
  800d4d:	68 5c 2e 80 00       	push   $0x802e5c
  800d52:	e8 b7 f4 ff ff       	call   80020e <_panic>

00800d57 <sys_page_map>:

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  800d57:	f3 0f 1e fb          	endbr32 
  800d5b:	55                   	push   %ebp
  800d5c:	89 e5                	mov    %esp,%ebp
  800d5e:	57                   	push   %edi
  800d5f:	56                   	push   %esi
  800d60:	53                   	push   %ebx
  800d61:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800d64:	8b 55 08             	mov    0x8(%ebp),%edx
  800d67:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800d6a:	b8 05 00 00 00       	mov    $0x5,%eax
  800d6f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800d72:	8b 7d 14             	mov    0x14(%ebp),%edi
  800d75:	8b 75 18             	mov    0x18(%ebp),%esi
  800d78:	cd 30                	int    $0x30
	if(check && ret > 0)
  800d7a:	85 c0                	test   %eax,%eax
  800d7c:	7f 08                	jg     800d86 <sys_page_map+0x2f>
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  800d7e:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800d81:	5b                   	pop    %ebx
  800d82:	5e                   	pop    %esi
  800d83:	5f                   	pop    %edi
  800d84:	5d                   	pop    %ebp
  800d85:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800d86:	83 ec 0c             	sub    $0xc,%esp
  800d89:	50                   	push   %eax
  800d8a:	6a 05                	push   $0x5
  800d8c:	68 3f 2e 80 00       	push   $0x802e3f
  800d91:	6a 23                	push   $0x23
  800d93:	68 5c 2e 80 00       	push   $0x802e5c
  800d98:	e8 71 f4 ff ff       	call   80020e <_panic>

00800d9d <sys_page_unmap>:

int
sys_page_unmap(envid_t envid, void *va)
{
  800d9d:	f3 0f 1e fb          	endbr32 
  800da1:	55                   	push   %ebp
  800da2:	89 e5                	mov    %esp,%ebp
  800da4:	57                   	push   %edi
  800da5:	56                   	push   %esi
  800da6:	53                   	push   %ebx
  800da7:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800daa:	bb 00 00 00 00       	mov    $0x0,%ebx
  800daf:	8b 55 08             	mov    0x8(%ebp),%edx
  800db2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800db5:	b8 06 00 00 00       	mov    $0x6,%eax
  800dba:	89 df                	mov    %ebx,%edi
  800dbc:	89 de                	mov    %ebx,%esi
  800dbe:	cd 30                	int    $0x30
	if(check && ret > 0)
  800dc0:	85 c0                	test   %eax,%eax
  800dc2:	7f 08                	jg     800dcc <sys_page_unmap+0x2f>
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  800dc4:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800dc7:	5b                   	pop    %ebx
  800dc8:	5e                   	pop    %esi
  800dc9:	5f                   	pop    %edi
  800dca:	5d                   	pop    %ebp
  800dcb:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800dcc:	83 ec 0c             	sub    $0xc,%esp
  800dcf:	50                   	push   %eax
  800dd0:	6a 06                	push   $0x6
  800dd2:	68 3f 2e 80 00       	push   $0x802e3f
  800dd7:	6a 23                	push   $0x23
  800dd9:	68 5c 2e 80 00       	push   $0x802e5c
  800dde:	e8 2b f4 ff ff       	call   80020e <_panic>

00800de3 <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  800de3:	f3 0f 1e fb          	endbr32 
  800de7:	55                   	push   %ebp
  800de8:	89 e5                	mov    %esp,%ebp
  800dea:	57                   	push   %edi
  800deb:	56                   	push   %esi
  800dec:	53                   	push   %ebx
  800ded:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800df0:	bb 00 00 00 00       	mov    $0x0,%ebx
  800df5:	8b 55 08             	mov    0x8(%ebp),%edx
  800df8:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800dfb:	b8 08 00 00 00       	mov    $0x8,%eax
  800e00:	89 df                	mov    %ebx,%edi
  800e02:	89 de                	mov    %ebx,%esi
  800e04:	cd 30                	int    $0x30
	if(check && ret > 0)
  800e06:	85 c0                	test   %eax,%eax
  800e08:	7f 08                	jg     800e12 <sys_env_set_status+0x2f>
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  800e0a:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800e0d:	5b                   	pop    %ebx
  800e0e:	5e                   	pop    %esi
  800e0f:	5f                   	pop    %edi
  800e10:	5d                   	pop    %ebp
  800e11:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800e12:	83 ec 0c             	sub    $0xc,%esp
  800e15:	50                   	push   %eax
  800e16:	6a 08                	push   $0x8
  800e18:	68 3f 2e 80 00       	push   $0x802e3f
  800e1d:	6a 23                	push   $0x23
  800e1f:	68 5c 2e 80 00       	push   $0x802e5c
  800e24:	e8 e5 f3 ff ff       	call   80020e <_panic>

00800e29 <sys_env_set_trapframe>:

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800e29:	f3 0f 1e fb          	endbr32 
  800e2d:	55                   	push   %ebp
  800e2e:	89 e5                	mov    %esp,%ebp
  800e30:	57                   	push   %edi
  800e31:	56                   	push   %esi
  800e32:	53                   	push   %ebx
  800e33:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800e36:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e3b:	8b 55 08             	mov    0x8(%ebp),%edx
  800e3e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e41:	b8 09 00 00 00       	mov    $0x9,%eax
  800e46:	89 df                	mov    %ebx,%edi
  800e48:	89 de                	mov    %ebx,%esi
  800e4a:	cd 30                	int    $0x30
	if(check && ret > 0)
  800e4c:	85 c0                	test   %eax,%eax
  800e4e:	7f 08                	jg     800e58 <sys_env_set_trapframe+0x2f>
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800e50:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800e53:	5b                   	pop    %ebx
  800e54:	5e                   	pop    %esi
  800e55:	5f                   	pop    %edi
  800e56:	5d                   	pop    %ebp
  800e57:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800e58:	83 ec 0c             	sub    $0xc,%esp
  800e5b:	50                   	push   %eax
  800e5c:	6a 09                	push   $0x9
  800e5e:	68 3f 2e 80 00       	push   $0x802e3f
  800e63:	6a 23                	push   $0x23
  800e65:	68 5c 2e 80 00       	push   $0x802e5c
  800e6a:	e8 9f f3 ff ff       	call   80020e <_panic>

00800e6f <sys_env_set_pgfault_upcall>:

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800e6f:	f3 0f 1e fb          	endbr32 
  800e73:	55                   	push   %ebp
  800e74:	89 e5                	mov    %esp,%ebp
  800e76:	57                   	push   %edi
  800e77:	56                   	push   %esi
  800e78:	53                   	push   %ebx
  800e79:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800e7c:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e81:	8b 55 08             	mov    0x8(%ebp),%edx
  800e84:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e87:	b8 0a 00 00 00       	mov    $0xa,%eax
  800e8c:	89 df                	mov    %ebx,%edi
  800e8e:	89 de                	mov    %ebx,%esi
  800e90:	cd 30                	int    $0x30
	if(check && ret > 0)
  800e92:	85 c0                	test   %eax,%eax
  800e94:	7f 08                	jg     800e9e <sys_env_set_pgfault_upcall+0x2f>
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800e96:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800e99:	5b                   	pop    %ebx
  800e9a:	5e                   	pop    %esi
  800e9b:	5f                   	pop    %edi
  800e9c:	5d                   	pop    %ebp
  800e9d:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800e9e:	83 ec 0c             	sub    $0xc,%esp
  800ea1:	50                   	push   %eax
  800ea2:	6a 0a                	push   $0xa
  800ea4:	68 3f 2e 80 00       	push   $0x802e3f
  800ea9:	6a 23                	push   $0x23
  800eab:	68 5c 2e 80 00       	push   $0x802e5c
  800eb0:	e8 59 f3 ff ff       	call   80020e <_panic>

00800eb5 <sys_ipc_try_send>:

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800eb5:	f3 0f 1e fb          	endbr32 
  800eb9:	55                   	push   %ebp
  800eba:	89 e5                	mov    %esp,%ebp
  800ebc:	57                   	push   %edi
  800ebd:	56                   	push   %esi
  800ebe:	53                   	push   %ebx
	asm volatile("int %1\n"
  800ebf:	8b 55 08             	mov    0x8(%ebp),%edx
  800ec2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ec5:	b8 0c 00 00 00       	mov    $0xc,%eax
  800eca:	be 00 00 00 00       	mov    $0x0,%esi
  800ecf:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800ed2:	8b 7d 14             	mov    0x14(%ebp),%edi
  800ed5:	cd 30                	int    $0x30
	return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
}
  800ed7:	5b                   	pop    %ebx
  800ed8:	5e                   	pop    %esi
  800ed9:	5f                   	pop    %edi
  800eda:	5d                   	pop    %ebp
  800edb:	c3                   	ret    

00800edc <sys_ipc_recv>:

int
sys_ipc_recv(void *dstva)
{
  800edc:	f3 0f 1e fb          	endbr32 
  800ee0:	55                   	push   %ebp
  800ee1:	89 e5                	mov    %esp,%ebp
  800ee3:	57                   	push   %edi
  800ee4:	56                   	push   %esi
  800ee5:	53                   	push   %ebx
  800ee6:	83 ec 0c             	sub    $0xc,%esp
	asm volatile("int %1\n"
  800ee9:	b9 00 00 00 00       	mov    $0x0,%ecx
  800eee:	8b 55 08             	mov    0x8(%ebp),%edx
  800ef1:	b8 0d 00 00 00       	mov    $0xd,%eax
  800ef6:	89 cb                	mov    %ecx,%ebx
  800ef8:	89 cf                	mov    %ecx,%edi
  800efa:	89 ce                	mov    %ecx,%esi
  800efc:	cd 30                	int    $0x30
	if(check && ret > 0)
  800efe:	85 c0                	test   %eax,%eax
  800f00:	7f 08                	jg     800f0a <sys_ipc_recv+0x2e>
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800f02:	8d 65 f4             	lea    -0xc(%ebp),%esp
  800f05:	5b                   	pop    %ebx
  800f06:	5e                   	pop    %esi
  800f07:	5f                   	pop    %edi
  800f08:	5d                   	pop    %ebp
  800f09:	c3                   	ret    
		panic("syscall %d returned %d (> 0)", num, ret);
  800f0a:	83 ec 0c             	sub    $0xc,%esp
  800f0d:	50                   	push   %eax
  800f0e:	6a 0d                	push   $0xd
  800f10:	68 3f 2e 80 00       	push   $0x802e3f
  800f15:	6a 23                	push   $0x23
  800f17:	68 5c 2e 80 00       	push   $0x802e5c
  800f1c:	e8 ed f2 ff ff       	call   80020e <_panic>

00800f21 <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  800f21:	f3 0f 1e fb          	endbr32 
  800f25:	55                   	push   %ebp
  800f26:	89 e5                	mov    %esp,%ebp
  800f28:	56                   	push   %esi
  800f29:	53                   	push   %ebx
  800f2a:	8b 45 08             	mov    0x8(%ebp),%eax
	void *addr = (void *) utf->utf_fault_va;
  800f2d:	8b 18                	mov    (%eax),%ebx
	/*
	将父进程空间中所有可以写的页表的部分全部标记为可读且COW【因此读取的时候不会进入pgfault，但是写的时候会触发pgfault】。
	而当父进程或者子进程任意一个发生了写的时候，因为页表现在都是不可写的，所以会触发异常，进入到我们设定的page fault处理例程，
	当检测到是对COW页的写操作的情况下，就可以将要写入的页的内容全部拷贝一份，重新映射。
	*/
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  800f2f:	f6 40 04 02          	testb  $0x2,0x4(%eax)
  800f33:	0f 84 b2 00 00 00    	je     800feb <pgfault+0xca>
  800f39:	89 d8                	mov    %ebx,%eax
  800f3b:	c1 e8 16             	shr    $0x16,%eax
  800f3e:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  800f45:	a8 01                	test   $0x1,%al
  800f47:	0f 84 9e 00 00 00    	je     800feb <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  800f4d:	89 d8                	mov    %ebx,%eax
  800f4f:	c1 e8 0c             	shr    $0xc,%eax
  800f52:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  800f59:	f6 c2 01             	test   $0x1,%dl
  800f5c:	0f 84 89 00 00 00    	je     800feb <pgfault+0xca>
			(uvpt[PGNUM(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_COW)))
  800f62:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
    if (!((err & FEC_WR) && (uvpd[PDX(addr)] & PTE_P) && 
  800f69:	f6 c4 08             	test   $0x8,%ah
  800f6c:	74 7d                	je     800feb <pgfault+0xca>
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
	//为该进程分配新的页面。
	envid_t envid=sys_getenvid();
  800f6e:	e8 57 fd ff ff       	call   800cca <sys_getenvid>
  800f73:	89 c6                	mov    %eax,%esi
	r=sys_page_alloc(envid,(void*)PFTEMP,PTE_P|PTE_U|PTE_W);
  800f75:	83 ec 04             	sub    $0x4,%esp
  800f78:	6a 07                	push   $0x7
  800f7a:	68 00 f0 7f 00       	push   $0x7ff000
  800f7f:	50                   	push   %eax
  800f80:	e8 8b fd ff ff       	call   800d10 <sys_page_alloc>
	if(r<0){
  800f85:	83 c4 10             	add    $0x10,%esp
  800f88:	85 c0                	test   %eax,%eax
  800f8a:	78 73                	js     800fff <pgfault+0xde>
		 panic("pgfault: page allocation failed %e", r);
	}
	//解开了我的疑惑，为什么随着fork页空间会逐渐发生偏移。
	//迁移数据过去。
	addr=ROUNDDOWN(addr,PGSIZE);
  800f8c:	81 e3 00 f0 ff ff    	and    $0xfffff000,%ebx
	//拷贝内容。
	memmove(PFTEMP,addr,PGSIZE);
  800f92:	83 ec 04             	sub    $0x4,%esp
  800f95:	68 00 10 00 00       	push   $0x1000
  800f9a:	53                   	push   %ebx
  800f9b:	68 00 f0 7f 00       	push   $0x7ff000
  800fa0:	e8 df fa ff ff       	call   800a84 <memmove>
	//解除和addr的映射关系。
	r=sys_page_unmap(envid,(void*)addr);
  800fa5:	83 c4 08             	add    $0x8,%esp
  800fa8:	53                   	push   %ebx
  800fa9:	56                   	push   %esi
  800faa:	e8 ee fd ff ff       	call   800d9d <sys_page_unmap>
	if(r<0)
  800faf:	83 c4 10             	add    $0x10,%esp
  800fb2:	85 c0                	test   %eax,%eax
  800fb4:	78 5b                	js     801011 <pgfault+0xf0>
	panic("pgfault: page unmap failed %e", r);
	r=sys_page_map(envid,PFTEMP,envid,addr,PTE_P|PTE_U|PTE_W);
  800fb6:	83 ec 0c             	sub    $0xc,%esp
  800fb9:	6a 07                	push   $0x7
  800fbb:	53                   	push   %ebx
  800fbc:	56                   	push   %esi
  800fbd:	68 00 f0 7f 00       	push   $0x7ff000
  800fc2:	56                   	push   %esi
  800fc3:	e8 8f fd ff ff       	call   800d57 <sys_page_map>
	if(r<0)
  800fc8:	83 c4 20             	add    $0x20,%esp
  800fcb:	85 c0                	test   %eax,%eax
  800fcd:	78 54                	js     801023 <pgfault+0x102>
	panic("pgfault: page map failed %e", r);
	r=sys_page_unmap(envid,PFTEMP);
  800fcf:	83 ec 08             	sub    $0x8,%esp
  800fd2:	68 00 f0 7f 00       	push   $0x7ff000
  800fd7:	56                   	push   %esi
  800fd8:	e8 c0 fd ff ff       	call   800d9d <sys_page_unmap>
	if(r<0)
  800fdd:	83 c4 10             	add    $0x10,%esp
  800fe0:	85 c0                	test   %eax,%eax
  800fe2:	78 51                	js     801035 <pgfault+0x114>
	panic("pgfault: page unmap failed %e", r);
}
  800fe4:	8d 65 f8             	lea    -0x8(%ebp),%esp
  800fe7:	5b                   	pop    %ebx
  800fe8:	5e                   	pop    %esi
  800fe9:	5d                   	pop    %ebp
  800fea:	c3                   	ret    
                panic("pgfault: it's not writable or attempt to access a non-cow page!");
  800feb:	83 ec 04             	sub    $0x4,%esp
  800fee:	68 6c 2e 80 00       	push   $0x802e6c
  800ff3:	6a 2c                	push   $0x2c
  800ff5:	68 1b 2f 80 00       	push   $0x802f1b
  800ffa:	e8 0f f2 ff ff       	call   80020e <_panic>
		 panic("pgfault: page allocation failed %e", r);
  800fff:	50                   	push   %eax
  801000:	68 ac 2e 80 00       	push   $0x802eac
  801005:	6a 31                	push   $0x31
  801007:	68 1b 2f 80 00       	push   $0x802f1b
  80100c:	e8 fd f1 ff ff       	call   80020e <_panic>
	panic("pgfault: page unmap failed %e", r);
  801011:	50                   	push   %eax
  801012:	68 26 2f 80 00       	push   $0x802f26
  801017:	6a 3b                	push   $0x3b
  801019:	68 1b 2f 80 00       	push   $0x802f1b
  80101e:	e8 eb f1 ff ff       	call   80020e <_panic>
	panic("pgfault: page map failed %e", r);
  801023:	50                   	push   %eax
  801024:	68 44 2f 80 00       	push   $0x802f44
  801029:	6a 3e                	push   $0x3e
  80102b:	68 1b 2f 80 00       	push   $0x802f1b
  801030:	e8 d9 f1 ff ff       	call   80020e <_panic>
	panic("pgfault: page unmap failed %e", r);
  801035:	50                   	push   %eax
  801036:	68 26 2f 80 00       	push   $0x802f26
  80103b:	6a 41                	push   $0x41
  80103d:	68 1b 2f 80 00       	push   $0x802f1b
  801042:	e8 c7 f1 ff ff       	call   80020e <_panic>

00801047 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  801047:	f3 0f 1e fb          	endbr32 
  80104b:	55                   	push   %ebp
  80104c:	89 e5                	mov    %esp,%ebp
  80104e:	57                   	push   %edi
  80104f:	56                   	push   %esi
  801050:	53                   	push   %ebx
  801051:	83 ec 28             	sub    $0x28,%esp
	// LAB 4: Your code here.
	envid_t envid;
	uintptr_t pageVa;
	unsigned pn;
	//设置pgfault情况下对应处理的函数。
	set_pgfault_handler(pgfault);
  801054:	68 21 0f 80 00       	push   $0x800f21
  801059:	e8 a8 15 00 00       	call   802606 <set_pgfault_handler>
// This must be inlined.  Exercise for reader: why?
static inline envid_t __attribute__((always_inline))
sys_exofork(void)
{
	envid_t ret;
	asm volatile("int %2"
  80105e:	b8 07 00 00 00       	mov    $0x7,%eax
  801063:	cd 30                	int    $0x30
  801065:	89 c7                	mov    %eax,%edi
  801067:	89 45 e4             	mov    %eax,-0x1c(%ebp)
	//首先需要分配一个env，env_alloc是内核态调用的，因此只能去调系统调用对应的函数来请求分配一个环境描述符。
	envid=sys_exofork();
	//分配成功
	if(envid>0){
  80106a:	83 c4 10             	add    $0x10,%esp
  80106d:	85 c0                	test   %eax,%eax
  80106f:	0f 8e 9d 01 00 00    	jle    801212 <fork+0x1cb>
		//接下来应该要拷贝父进程。当然这里让我吃惊的是直接可以调用对应的宏并且并没有去请求父进程。jos系统似乎是把所有的子进程都来源于同一进程，而不是父子继承关系。
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  801075:	bb 00 00 80 00       	mov    $0x800000,%ebx
  80107a:	eb 5b                	jmp    8010d7 <fork+0x90>
			sys_page_map(0, addr, envid, addr, PTE_SYSCALL);
  80107c:	83 ec 0c             	sub    $0xc,%esp
  80107f:	68 07 0e 00 00       	push   $0xe07
  801084:	56                   	push   %esi
  801085:	ff 75 e4             	pushl  -0x1c(%ebp)
  801088:	56                   	push   %esi
  801089:	6a 00                	push   $0x0
  80108b:	e8 c7 fc ff ff       	call   800d57 <sys_page_map>
  801090:	83 c4 20             	add    $0x20,%esp
  801093:	eb 30                	jmp    8010c5 <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  801095:	83 ec 04             	sub    $0x4,%esp
  801098:	68 60 2f 80 00       	push   $0x802f60
  80109d:	6a 63                	push   $0x63
  80109f:	68 1b 2f 80 00       	push   $0x802f1b
  8010a4:	e8 65 f1 ff ff       	call   80020e <_panic>
            r = sys_page_map(0, addr, envid, addr, PTE_U | PTE_P);
  8010a9:	83 ec 0c             	sub    $0xc,%esp
  8010ac:	6a 05                	push   $0x5
  8010ae:	56                   	push   %esi
  8010af:	ff 75 e4             	pushl  -0x1c(%ebp)
  8010b2:	56                   	push   %esi
  8010b3:	6a 00                	push   $0x0
  8010b5:	e8 9d fc ff ff       	call   800d57 <sys_page_map>
            if(r < 0)
  8010ba:	83 c4 20             	add    $0x20,%esp
  8010bd:	85 c0                	test   %eax,%eax
  8010bf:	0f 88 ac 00 00 00    	js     801171 <fork+0x12a>
		for(pageVa=UTEXT;pageVa<USTACKTOP;pageVa+=PGSIZE){
  8010c5:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  8010cb:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  8010d1:	0f 84 ae 00 00 00    	je     801185 <fork+0x13e>
			pn=PGNUM(pageVa);
			//检查权限，挨个copy页
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  8010d7:	89 d8                	mov    %ebx,%eax
  8010d9:	c1 e8 16             	shr    $0x16,%eax
  8010dc:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8010e3:	a8 01                	test   $0x1,%al
  8010e5:	74 de                	je     8010c5 <fork+0x7e>
			pn=PGNUM(pageVa);
  8010e7:	89 d8                	mov    %ebx,%eax
  8010e9:	c1 e8 0c             	shr    $0xc,%eax
			if((uvpd[PDX(pageVa)]&PTE_P)&&(uvpt[pn]&PTE_P)&&(uvpt[pn]&PTE_U)){
  8010ec:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  8010f3:	f6 c2 01             	test   $0x1,%dl
  8010f6:	74 cd                	je     8010c5 <fork+0x7e>
  8010f8:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  8010ff:	f6 c2 04             	test   $0x4,%dl
  801102:	74 c1                	je     8010c5 <fork+0x7e>
        addr = (void *)((uint32_t)pn * PGSIZE);
  801104:	89 c6                	mov    %eax,%esi
  801106:	c1 e6 0c             	shl    $0xc,%esi
        pte = uvpt[pn];
  801109:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
		if(pte&PTE_SHARE){
  801110:	f6 c4 04             	test   $0x4,%ah
  801113:	0f 85 63 ff ff ff    	jne    80107c <fork+0x35>
        else if((pte & PTE_COW) || (pte & PTE_W))
  801119:	a9 02 08 00 00       	test   $0x802,%eax
  80111e:	74 89                	je     8010a9 <fork+0x62>
            r = sys_page_map(0, addr, envid, addr, PTE_COW | PTE_U | PTE_P);
  801120:	83 ec 0c             	sub    $0xc,%esp
  801123:	68 05 08 00 00       	push   $0x805
  801128:	56                   	push   %esi
  801129:	ff 75 e4             	pushl  -0x1c(%ebp)
  80112c:	56                   	push   %esi
  80112d:	6a 00                	push   $0x0
  80112f:	e8 23 fc ff ff       	call   800d57 <sys_page_map>
            if(r < 0)
  801134:	83 c4 20             	add    $0x20,%esp
  801137:	85 c0                	test   %eax,%eax
  801139:	0f 88 56 ff ff ff    	js     801095 <fork+0x4e>
            r = sys_page_map(0, addr, 0, addr, PTE_COW | PTE_U | PTE_P);
  80113f:	83 ec 0c             	sub    $0xc,%esp
  801142:	68 05 08 00 00       	push   $0x805
  801147:	56                   	push   %esi
  801148:	6a 00                	push   $0x0
  80114a:	56                   	push   %esi
  80114b:	6a 00                	push   $0x0
  80114d:	e8 05 fc ff ff       	call   800d57 <sys_page_map>
            if(r < 0)
  801152:	83 c4 20             	add    $0x20,%esp
  801155:	85 c0                	test   %eax,%eax
  801157:	0f 89 68 ff ff ff    	jns    8010c5 <fork+0x7e>
                panic("duppage: sys_page_map fail\n");
  80115d:	83 ec 04             	sub    $0x4,%esp
  801160:	68 60 2f 80 00       	push   $0x802f60
  801165:	6a 66                	push   $0x66
  801167:	68 1b 2f 80 00       	push   $0x802f1b
  80116c:	e8 9d f0 ff ff       	call   80020e <_panic>
                panic("duppage: sys_page_map fail\n");
  801171:	83 ec 04             	sub    $0x4,%esp
  801174:	68 60 2f 80 00       	push   $0x802f60
  801179:	6a 6c                	push   $0x6c
  80117b:	68 1b 2f 80 00       	push   $0x802f1b
  801180:	e8 89 f0 ff ff       	call   80020e <_panic>
				duppage(envid,pn);}
			}
		//分配异常栈。
		int32_t flag=sys_page_alloc(envid,(void*)(UXSTACKTOP-PGSIZE),PTE_P|PTE_U|PTE_W);
  801185:	83 ec 04             	sub    $0x4,%esp
  801188:	6a 07                	push   $0x7
  80118a:	68 00 f0 bf ee       	push   $0xeebff000
  80118f:	57                   	push   %edi
  801190:	e8 7b fb ff ff       	call   800d10 <sys_page_alloc>
		if(flag<0){
  801195:	83 c4 10             	add    $0x10,%esp
  801198:	85 c0                	test   %eax,%eax
  80119a:	78 31                	js     8011cd <fork+0x186>
			panic("panic by alloc page");
		}
		//设置对应的异常处理函数。
		extern void _pgfault_upcall(void);
		flag=sys_env_set_pgfault_upcall(envid,_pgfault_upcall);
  80119c:	83 ec 08             	sub    $0x8,%esp
  80119f:	68 80 26 80 00       	push   $0x802680
  8011a4:	57                   	push   %edi
  8011a5:	e8 c5 fc ff ff       	call   800e6f <sys_env_set_pgfault_upcall>
		if(flag<0){
  8011aa:	83 c4 10             	add    $0x10,%esp
  8011ad:	85 c0                	test   %eax,%eax
  8011af:	78 33                	js     8011e4 <fork+0x19d>
			panic("panic by set pgfault upcall faction");
		}
		//设置子进程，等待调度。
		flag=sys_env_set_status(envid,ENV_RUNNABLE);
  8011b1:	83 ec 08             	sub    $0x8,%esp
  8011b4:	6a 02                	push   $0x2
  8011b6:	57                   	push   %edi
  8011b7:	e8 27 fc ff ff       	call   800de3 <sys_env_set_status>
		if(flag<0){
  8011bc:	83 c4 10             	add    $0x10,%esp
  8011bf:	85 c0                	test   %eax,%eax
  8011c1:	78 38                	js     8011fb <fork+0x1b4>
		//否则报错。
		panic("panic by alloc envid");
	}

	
}
  8011c3:	89 f8                	mov    %edi,%eax
  8011c5:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8011c8:	5b                   	pop    %ebx
  8011c9:	5e                   	pop    %esi
  8011ca:	5f                   	pop    %edi
  8011cb:	5d                   	pop    %ebp
  8011cc:	c3                   	ret    
			panic("panic by alloc page");
  8011cd:	83 ec 04             	sub    $0x4,%esp
  8011d0:	68 7c 2f 80 00       	push   $0x802f7c
  8011d5:	68 98 00 00 00       	push   $0x98
  8011da:	68 1b 2f 80 00       	push   $0x802f1b
  8011df:	e8 2a f0 ff ff       	call   80020e <_panic>
			panic("panic by set pgfault upcall faction");
  8011e4:	83 ec 04             	sub    $0x4,%esp
  8011e7:	68 d0 2e 80 00       	push   $0x802ed0
  8011ec:	68 9e 00 00 00       	push   $0x9e
  8011f1:	68 1b 2f 80 00       	push   $0x802f1b
  8011f6:	e8 13 f0 ff ff       	call   80020e <_panic>
			panic("panic by set env status to ENV_RUNABLE");
  8011fb:	83 ec 04             	sub    $0x4,%esp
  8011fe:	68 f4 2e 80 00       	push   $0x802ef4
  801203:	68 a3 00 00 00       	push   $0xa3
  801208:	68 1b 2f 80 00       	push   $0x802f1b
  80120d:	e8 fc ef ff ff       	call   80020e <_panic>
	else if(envid==0){
  801212:	75 19                	jne    80122d <fork+0x1e6>
        thisenv = &envs[ENVX(sys_getenvid())];	//在子进程中设置thisenv为自己
  801214:	e8 b1 fa ff ff       	call   800cca <sys_getenvid>
  801219:	25 ff 03 00 00       	and    $0x3ff,%eax
  80121e:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801221:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  801226:	a3 04 50 80 00       	mov    %eax,0x805004
		return 0;
  80122b:	eb 96                	jmp    8011c3 <fork+0x17c>
		panic("panic by alloc envid");
  80122d:	83 ec 04             	sub    $0x4,%esp
  801230:	68 90 2f 80 00       	push   $0x802f90
  801235:	68 ad 00 00 00       	push   $0xad
  80123a:	68 1b 2f 80 00       	push   $0x802f1b
  80123f:	e8 ca ef ff ff       	call   80020e <_panic>

00801244 <sfork>:

// Challenge!
int
sfork(void)
{
  801244:	f3 0f 1e fb          	endbr32 
  801248:	55                   	push   %ebp
  801249:	89 e5                	mov    %esp,%ebp
  80124b:	83 ec 0c             	sub    $0xc,%esp
	panic("sfork not implemented");
  80124e:	68 a5 2f 80 00       	push   $0x802fa5
  801253:	68 b7 00 00 00       	push   $0xb7
  801258:	68 1b 2f 80 00       	push   $0x802f1b
  80125d:	e8 ac ef ff ff       	call   80020e <_panic>

00801262 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801262:	f3 0f 1e fb          	endbr32 
  801266:	55                   	push   %ebp
  801267:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  801269:	8b 45 08             	mov    0x8(%ebp),%eax
  80126c:	05 00 00 00 30       	add    $0x30000000,%eax
  801271:	c1 e8 0c             	shr    $0xc,%eax
}
  801274:	5d                   	pop    %ebp
  801275:	c3                   	ret    

00801276 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801276:	f3 0f 1e fb          	endbr32 
  80127a:	55                   	push   %ebp
  80127b:	89 e5                	mov    %esp,%ebp
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  80127d:	8b 45 08             	mov    0x8(%ebp),%eax
  801280:	05 00 00 00 30       	add    $0x30000000,%eax
	return INDEX2DATA(fd2num(fd));
  801285:	25 00 f0 ff ff       	and    $0xfffff000,%eax
  80128a:	2d 00 00 fe 2f       	sub    $0x2ffe0000,%eax
}
  80128f:	5d                   	pop    %ebp
  801290:	c3                   	ret    

00801291 <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  801291:	f3 0f 1e fb          	endbr32 
  801295:	55                   	push   %ebp
  801296:	89 e5                	mov    %esp,%ebp
  801298:	b8 00 00 00 d0       	mov    $0xd0000000,%eax
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((uvpd[PDX(fd)] & PTE_P) == 0 || (uvpt[PGNUM(fd)] & PTE_P) == 0) {
  80129d:	89 c2                	mov    %eax,%edx
  80129f:	c1 ea 16             	shr    $0x16,%edx
  8012a2:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8012a9:	f6 c2 01             	test   $0x1,%dl
  8012ac:	74 2d                	je     8012db <fd_alloc+0x4a>
  8012ae:	89 c2                	mov    %eax,%edx
  8012b0:	c1 ea 0c             	shr    $0xc,%edx
  8012b3:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8012ba:	f6 c2 01             	test   $0x1,%dl
  8012bd:	74 1c                	je     8012db <fd_alloc+0x4a>
  8012bf:	05 00 10 00 00       	add    $0x1000,%eax
	for (i = 0; i < MAXFD; i++) {
  8012c4:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8012c9:	75 d2                	jne    80129d <fd_alloc+0xc>
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8012cb:	8b 45 08             	mov    0x8(%ebp),%eax
  8012ce:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_MAX_OPEN;
  8012d4:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
  8012d9:	eb 0a                	jmp    8012e5 <fd_alloc+0x54>
			*fd_store = fd;
  8012db:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8012de:	89 01                	mov    %eax,(%ecx)
			return 0;
  8012e0:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8012e5:	5d                   	pop    %ebp
  8012e6:	c3                   	ret    

008012e7 <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8012e7:	f3 0f 1e fb          	endbr32 
  8012eb:	55                   	push   %ebp
  8012ec:	89 e5                	mov    %esp,%ebp
  8012ee:	8b 45 08             	mov    0x8(%ebp),%eax
	struct Fd *fd;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8012f1:	83 f8 1f             	cmp    $0x1f,%eax
  8012f4:	77 30                	ja     801326 <fd_lookup+0x3f>
		if (debug)
			cprintf("[%08x] bad fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8012f6:	c1 e0 0c             	shl    $0xc,%eax
  8012f9:	2d 00 00 00 30       	sub    $0x30000000,%eax
	if (!(uvpd[PDX(fd)] & PTE_P) || !(uvpt[PGNUM(fd)] & PTE_P)) {
  8012fe:	8b 15 00 dd 7b ef    	mov    0xef7bdd00,%edx
  801304:	f6 c2 01             	test   $0x1,%dl
  801307:	74 24                	je     80132d <fd_lookup+0x46>
  801309:	89 c2                	mov    %eax,%edx
  80130b:	c1 ea 0c             	shr    $0xc,%edx
  80130e:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801315:	f6 c2 01             	test   $0x1,%dl
  801318:	74 1a                	je     801334 <fd_lookup+0x4d>
		if (debug)
			cprintf("[%08x] closed fd %d\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	*fd_store = fd;
  80131a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80131d:	89 02                	mov    %eax,(%edx)
	return 0;
  80131f:	b8 00 00 00 00       	mov    $0x0,%eax
}
  801324:	5d                   	pop    %ebp
  801325:	c3                   	ret    
		return -E_INVAL;
  801326:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80132b:	eb f7                	jmp    801324 <fd_lookup+0x3d>
		return -E_INVAL;
  80132d:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801332:	eb f0                	jmp    801324 <fd_lookup+0x3d>
  801334:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  801339:	eb e9                	jmp    801324 <fd_lookup+0x3d>

0080133b <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  80133b:	f3 0f 1e fb          	endbr32 
  80133f:	55                   	push   %ebp
  801340:	89 e5                	mov    %esp,%ebp
  801342:	83 ec 08             	sub    $0x8,%esp
  801345:	8b 4d 08             	mov    0x8(%ebp),%ecx
  801348:	ba 38 30 80 00       	mov    $0x803038,%edx
	int i;
	for (i = 0; devtab[i]; i++)
  80134d:	b8 0c 40 80 00       	mov    $0x80400c,%eax
		if (devtab[i]->dev_id == dev_id) {
  801352:	39 08                	cmp    %ecx,(%eax)
  801354:	74 33                	je     801389 <dev_lookup+0x4e>
  801356:	83 c2 04             	add    $0x4,%edx
	for (i = 0; devtab[i]; i++)
  801359:	8b 02                	mov    (%edx),%eax
  80135b:	85 c0                	test   %eax,%eax
  80135d:	75 f3                	jne    801352 <dev_lookup+0x17>
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", thisenv->env_id, dev_id);
  80135f:	a1 04 50 80 00       	mov    0x805004,%eax
  801364:	8b 40 48             	mov    0x48(%eax),%eax
  801367:	83 ec 04             	sub    $0x4,%esp
  80136a:	51                   	push   %ecx
  80136b:	50                   	push   %eax
  80136c:	68 bc 2f 80 00       	push   $0x802fbc
  801371:	e8 7f ef ff ff       	call   8002f5 <cprintf>
	*dev = 0;
  801376:	8b 45 0c             	mov    0xc(%ebp),%eax
  801379:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
	return -E_INVAL;
  80137f:	83 c4 10             	add    $0x10,%esp
  801382:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801387:	c9                   	leave  
  801388:	c3                   	ret    
			*dev = devtab[i];
  801389:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80138c:	89 01                	mov    %eax,(%ecx)
			return 0;
  80138e:	b8 00 00 00 00       	mov    $0x0,%eax
  801393:	eb f2                	jmp    801387 <dev_lookup+0x4c>

00801395 <fd_close>:
{
  801395:	f3 0f 1e fb          	endbr32 
  801399:	55                   	push   %ebp
  80139a:	89 e5                	mov    %esp,%ebp
  80139c:	57                   	push   %edi
  80139d:	56                   	push   %esi
  80139e:	53                   	push   %ebx
  80139f:	83 ec 24             	sub    $0x24,%esp
  8013a2:	8b 75 08             	mov    0x8(%ebp),%esi
  8013a5:	8b 7d 0c             	mov    0xc(%ebp),%edi
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  8013a8:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8013ab:	50                   	push   %eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
  8013ac:	8d 86 00 00 00 30    	lea    0x30000000(%esi),%eax
  8013b2:	c1 e8 0c             	shr    $0xc,%eax
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  8013b5:	50                   	push   %eax
  8013b6:	e8 2c ff ff ff       	call   8012e7 <fd_lookup>
  8013bb:	89 c3                	mov    %eax,%ebx
  8013bd:	83 c4 10             	add    $0x10,%esp
  8013c0:	85 c0                	test   %eax,%eax
  8013c2:	78 05                	js     8013c9 <fd_close+0x34>
	    || fd != fd2)
  8013c4:	39 75 e4             	cmp    %esi,-0x1c(%ebp)
  8013c7:	74 16                	je     8013df <fd_close+0x4a>
		return (must_exist ? r : 0);
  8013c9:	89 f8                	mov    %edi,%eax
  8013cb:	84 c0                	test   %al,%al
  8013cd:	b8 00 00 00 00       	mov    $0x0,%eax
  8013d2:	0f 44 d8             	cmove  %eax,%ebx
}
  8013d5:	89 d8                	mov    %ebx,%eax
  8013d7:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8013da:	5b                   	pop    %ebx
  8013db:	5e                   	pop    %esi
  8013dc:	5f                   	pop    %edi
  8013dd:	5d                   	pop    %ebp
  8013de:	c3                   	ret    
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  8013df:	83 ec 08             	sub    $0x8,%esp
  8013e2:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8013e5:	50                   	push   %eax
  8013e6:	ff 36                	pushl  (%esi)
  8013e8:	e8 4e ff ff ff       	call   80133b <dev_lookup>
  8013ed:	89 c3                	mov    %eax,%ebx
  8013ef:	83 c4 10             	add    $0x10,%esp
  8013f2:	85 c0                	test   %eax,%eax
  8013f4:	78 1a                	js     801410 <fd_close+0x7b>
		if (dev->dev_close)
  8013f6:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8013f9:	8b 40 10             	mov    0x10(%eax),%eax
			r = 0;
  8013fc:	bb 00 00 00 00       	mov    $0x0,%ebx
		if (dev->dev_close)
  801401:	85 c0                	test   %eax,%eax
  801403:	74 0b                	je     801410 <fd_close+0x7b>
			r = (*dev->dev_close)(fd);
  801405:	83 ec 0c             	sub    $0xc,%esp
  801408:	56                   	push   %esi
  801409:	ff d0                	call   *%eax
  80140b:	89 c3                	mov    %eax,%ebx
  80140d:	83 c4 10             	add    $0x10,%esp
	(void) sys_page_unmap(0, fd);
  801410:	83 ec 08             	sub    $0x8,%esp
  801413:	56                   	push   %esi
  801414:	6a 00                	push   $0x0
  801416:	e8 82 f9 ff ff       	call   800d9d <sys_page_unmap>
	return r;
  80141b:	83 c4 10             	add    $0x10,%esp
  80141e:	eb b5                	jmp    8013d5 <fd_close+0x40>

00801420 <close>:

int
close(int fdnum)
{
  801420:	f3 0f 1e fb          	endbr32 
  801424:	55                   	push   %ebp
  801425:	89 e5                	mov    %esp,%ebp
  801427:	83 ec 20             	sub    $0x20,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80142a:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80142d:	50                   	push   %eax
  80142e:	ff 75 08             	pushl  0x8(%ebp)
  801431:	e8 b1 fe ff ff       	call   8012e7 <fd_lookup>
  801436:	83 c4 10             	add    $0x10,%esp
  801439:	85 c0                	test   %eax,%eax
  80143b:	79 02                	jns    80143f <close+0x1f>
		return r;
	else
		return fd_close(fd, 1);
}
  80143d:	c9                   	leave  
  80143e:	c3                   	ret    
		return fd_close(fd, 1);
  80143f:	83 ec 08             	sub    $0x8,%esp
  801442:	6a 01                	push   $0x1
  801444:	ff 75 f4             	pushl  -0xc(%ebp)
  801447:	e8 49 ff ff ff       	call   801395 <fd_close>
  80144c:	83 c4 10             	add    $0x10,%esp
  80144f:	eb ec                	jmp    80143d <close+0x1d>

00801451 <close_all>:

void
close_all(void)
{
  801451:	f3 0f 1e fb          	endbr32 
  801455:	55                   	push   %ebp
  801456:	89 e5                	mov    %esp,%ebp
  801458:	53                   	push   %ebx
  801459:	83 ec 04             	sub    $0x4,%esp
	int i;
	for (i = 0; i < MAXFD; i++)
  80145c:	bb 00 00 00 00       	mov    $0x0,%ebx
		close(i);
  801461:	83 ec 0c             	sub    $0xc,%esp
  801464:	53                   	push   %ebx
  801465:	e8 b6 ff ff ff       	call   801420 <close>
	for (i = 0; i < MAXFD; i++)
  80146a:	83 c3 01             	add    $0x1,%ebx
  80146d:	83 c4 10             	add    $0x10,%esp
  801470:	83 fb 20             	cmp    $0x20,%ebx
  801473:	75 ec                	jne    801461 <close_all+0x10>
}
  801475:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  801478:	c9                   	leave  
  801479:	c3                   	ret    

0080147a <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  80147a:	f3 0f 1e fb          	endbr32 
  80147e:	55                   	push   %ebp
  80147f:	89 e5                	mov    %esp,%ebp
  801481:	57                   	push   %edi
  801482:	56                   	push   %esi
  801483:	53                   	push   %ebx
  801484:	83 ec 24             	sub    $0x24,%esp
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801487:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80148a:	50                   	push   %eax
  80148b:	ff 75 08             	pushl  0x8(%ebp)
  80148e:	e8 54 fe ff ff       	call   8012e7 <fd_lookup>
  801493:	89 c3                	mov    %eax,%ebx
  801495:	83 c4 10             	add    $0x10,%esp
  801498:	85 c0                	test   %eax,%eax
  80149a:	0f 88 81 00 00 00    	js     801521 <dup+0xa7>
		return r;
	close(newfdnum);
  8014a0:	83 ec 0c             	sub    $0xc,%esp
  8014a3:	ff 75 0c             	pushl  0xc(%ebp)
  8014a6:	e8 75 ff ff ff       	call   801420 <close>

	newfd = INDEX2FD(newfdnum);
  8014ab:	8b 75 0c             	mov    0xc(%ebp),%esi
  8014ae:	c1 e6 0c             	shl    $0xc,%esi
  8014b1:	81 ee 00 00 00 30    	sub    $0x30000000,%esi
	ova = fd2data(oldfd);
  8014b7:	83 c4 04             	add    $0x4,%esp
  8014ba:	ff 75 e4             	pushl  -0x1c(%ebp)
  8014bd:	e8 b4 fd ff ff       	call   801276 <fd2data>
  8014c2:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  8014c4:	89 34 24             	mov    %esi,(%esp)
  8014c7:	e8 aa fd ff ff       	call   801276 <fd2data>
  8014cc:	83 c4 10             	add    $0x10,%esp
  8014cf:	89 c7                	mov    %eax,%edi

	if ((uvpd[PDX(ova)] & PTE_P) && (uvpt[PGNUM(ova)] & PTE_P))
  8014d1:	89 d8                	mov    %ebx,%eax
  8014d3:	c1 e8 16             	shr    $0x16,%eax
  8014d6:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8014dd:	a8 01                	test   $0x1,%al
  8014df:	74 11                	je     8014f2 <dup+0x78>
  8014e1:	89 d8                	mov    %ebx,%eax
  8014e3:	c1 e8 0c             	shr    $0xc,%eax
  8014e6:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  8014ed:	f6 c2 01             	test   $0x1,%dl
  8014f0:	75 39                	jne    80152b <dup+0xb1>
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, uvpt[PGNUM(oldfd)] & PTE_SYSCALL)) < 0)
  8014f2:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8014f5:	89 d0                	mov    %edx,%eax
  8014f7:	c1 e8 0c             	shr    $0xc,%eax
  8014fa:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801501:	83 ec 0c             	sub    $0xc,%esp
  801504:	25 07 0e 00 00       	and    $0xe07,%eax
  801509:	50                   	push   %eax
  80150a:	56                   	push   %esi
  80150b:	6a 00                	push   $0x0
  80150d:	52                   	push   %edx
  80150e:	6a 00                	push   $0x0
  801510:	e8 42 f8 ff ff       	call   800d57 <sys_page_map>
  801515:	89 c3                	mov    %eax,%ebx
  801517:	83 c4 20             	add    $0x20,%esp
  80151a:	85 c0                	test   %eax,%eax
  80151c:	78 31                	js     80154f <dup+0xd5>
		goto err;

	return newfdnum;
  80151e:	8b 5d 0c             	mov    0xc(%ebp),%ebx

err:
	sys_page_unmap(0, newfd);
	sys_page_unmap(0, nva);
	return r;
}
  801521:	89 d8                	mov    %ebx,%eax
  801523:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801526:	5b                   	pop    %ebx
  801527:	5e                   	pop    %esi
  801528:	5f                   	pop    %edi
  801529:	5d                   	pop    %ebp
  80152a:	c3                   	ret    
		if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
  80152b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801532:	83 ec 0c             	sub    $0xc,%esp
  801535:	25 07 0e 00 00       	and    $0xe07,%eax
  80153a:	50                   	push   %eax
  80153b:	57                   	push   %edi
  80153c:	6a 00                	push   $0x0
  80153e:	53                   	push   %ebx
  80153f:	6a 00                	push   $0x0
  801541:	e8 11 f8 ff ff       	call   800d57 <sys_page_map>
  801546:	89 c3                	mov    %eax,%ebx
  801548:	83 c4 20             	add    $0x20,%esp
  80154b:	85 c0                	test   %eax,%eax
  80154d:	79 a3                	jns    8014f2 <dup+0x78>
	sys_page_unmap(0, newfd);
  80154f:	83 ec 08             	sub    $0x8,%esp
  801552:	56                   	push   %esi
  801553:	6a 00                	push   $0x0
  801555:	e8 43 f8 ff ff       	call   800d9d <sys_page_unmap>
	sys_page_unmap(0, nva);
  80155a:	83 c4 08             	add    $0x8,%esp
  80155d:	57                   	push   %edi
  80155e:	6a 00                	push   $0x0
  801560:	e8 38 f8 ff ff       	call   800d9d <sys_page_unmap>
	return r;
  801565:	83 c4 10             	add    $0x10,%esp
  801568:	eb b7                	jmp    801521 <dup+0xa7>

0080156a <read>:

ssize_t
read(int fdnum, void *buf, size_t n)
{
  80156a:	f3 0f 1e fb          	endbr32 
  80156e:	55                   	push   %ebp
  80156f:	89 e5                	mov    %esp,%ebp
  801571:	53                   	push   %ebx
  801572:	83 ec 1c             	sub    $0x1c,%esp
  801575:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801578:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80157b:	50                   	push   %eax
  80157c:	53                   	push   %ebx
  80157d:	e8 65 fd ff ff       	call   8012e7 <fd_lookup>
  801582:	83 c4 10             	add    $0x10,%esp
  801585:	85 c0                	test   %eax,%eax
  801587:	78 3f                	js     8015c8 <read+0x5e>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801589:	83 ec 08             	sub    $0x8,%esp
  80158c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80158f:	50                   	push   %eax
  801590:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801593:	ff 30                	pushl  (%eax)
  801595:	e8 a1 fd ff ff       	call   80133b <dev_lookup>
  80159a:	83 c4 10             	add    $0x10,%esp
  80159d:	85 c0                	test   %eax,%eax
  80159f:	78 27                	js     8015c8 <read+0x5e>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  8015a1:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8015a4:	8b 42 08             	mov    0x8(%edx),%eax
  8015a7:	83 e0 03             	and    $0x3,%eax
  8015aa:	83 f8 01             	cmp    $0x1,%eax
  8015ad:	74 1e                	je     8015cd <read+0x63>
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_read)
  8015af:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8015b2:	8b 40 08             	mov    0x8(%eax),%eax
  8015b5:	85 c0                	test   %eax,%eax
  8015b7:	74 35                	je     8015ee <read+0x84>
		return -E_NOT_SUPP;
	return (*dev->dev_read)(fd, buf, n);
  8015b9:	83 ec 04             	sub    $0x4,%esp
  8015bc:	ff 75 10             	pushl  0x10(%ebp)
  8015bf:	ff 75 0c             	pushl  0xc(%ebp)
  8015c2:	52                   	push   %edx
  8015c3:	ff d0                	call   *%eax
  8015c5:	83 c4 10             	add    $0x10,%esp
}
  8015c8:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8015cb:	c9                   	leave  
  8015cc:	c3                   	ret    
		cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
  8015cd:	a1 04 50 80 00       	mov    0x805004,%eax
  8015d2:	8b 40 48             	mov    0x48(%eax),%eax
  8015d5:	83 ec 04             	sub    $0x4,%esp
  8015d8:	53                   	push   %ebx
  8015d9:	50                   	push   %eax
  8015da:	68 fd 2f 80 00       	push   $0x802ffd
  8015df:	e8 11 ed ff ff       	call   8002f5 <cprintf>
		return -E_INVAL;
  8015e4:	83 c4 10             	add    $0x10,%esp
  8015e7:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8015ec:	eb da                	jmp    8015c8 <read+0x5e>
		return -E_NOT_SUPP;
  8015ee:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8015f3:	eb d3                	jmp    8015c8 <read+0x5e>

008015f5 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  8015f5:	f3 0f 1e fb          	endbr32 
  8015f9:	55                   	push   %ebp
  8015fa:	89 e5                	mov    %esp,%ebp
  8015fc:	57                   	push   %edi
  8015fd:	56                   	push   %esi
  8015fe:	53                   	push   %ebx
  8015ff:	83 ec 0c             	sub    $0xc,%esp
  801602:	8b 7d 08             	mov    0x8(%ebp),%edi
  801605:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;

	for (tot = 0; tot < n; tot += m) {
  801608:	bb 00 00 00 00       	mov    $0x0,%ebx
  80160d:	eb 02                	jmp    801611 <readn+0x1c>
  80160f:	01 c3                	add    %eax,%ebx
  801611:	39 f3                	cmp    %esi,%ebx
  801613:	73 21                	jae    801636 <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801615:	83 ec 04             	sub    $0x4,%esp
  801618:	89 f0                	mov    %esi,%eax
  80161a:	29 d8                	sub    %ebx,%eax
  80161c:	50                   	push   %eax
  80161d:	89 d8                	mov    %ebx,%eax
  80161f:	03 45 0c             	add    0xc(%ebp),%eax
  801622:	50                   	push   %eax
  801623:	57                   	push   %edi
  801624:	e8 41 ff ff ff       	call   80156a <read>
		if (m < 0)
  801629:	83 c4 10             	add    $0x10,%esp
  80162c:	85 c0                	test   %eax,%eax
  80162e:	78 04                	js     801634 <readn+0x3f>
			return m;
		if (m == 0)
  801630:	75 dd                	jne    80160f <readn+0x1a>
  801632:	eb 02                	jmp    801636 <readn+0x41>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801634:	89 c3                	mov    %eax,%ebx
			break;
	}
	return tot;
}
  801636:	89 d8                	mov    %ebx,%eax
  801638:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80163b:	5b                   	pop    %ebx
  80163c:	5e                   	pop    %esi
  80163d:	5f                   	pop    %edi
  80163e:	5d                   	pop    %ebp
  80163f:	c3                   	ret    

00801640 <write>:

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  801640:	f3 0f 1e fb          	endbr32 
  801644:	55                   	push   %ebp
  801645:	89 e5                	mov    %esp,%ebp
  801647:	53                   	push   %ebx
  801648:	83 ec 1c             	sub    $0x1c,%esp
  80164b:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80164e:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801651:	50                   	push   %eax
  801652:	53                   	push   %ebx
  801653:	e8 8f fc ff ff       	call   8012e7 <fd_lookup>
  801658:	83 c4 10             	add    $0x10,%esp
  80165b:	85 c0                	test   %eax,%eax
  80165d:	78 3a                	js     801699 <write+0x59>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80165f:	83 ec 08             	sub    $0x8,%esp
  801662:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801665:	50                   	push   %eax
  801666:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801669:	ff 30                	pushl  (%eax)
  80166b:	e8 cb fc ff ff       	call   80133b <dev_lookup>
  801670:	83 c4 10             	add    $0x10,%esp
  801673:	85 c0                	test   %eax,%eax
  801675:	78 22                	js     801699 <write+0x59>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  801677:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80167a:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  80167e:	74 1e                	je     80169e <write+0x5e>
		return -E_INVAL;
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  801680:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801683:	8b 52 0c             	mov    0xc(%edx),%edx
  801686:	85 d2                	test   %edx,%edx
  801688:	74 35                	je     8016bf <write+0x7f>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  80168a:	83 ec 04             	sub    $0x4,%esp
  80168d:	ff 75 10             	pushl  0x10(%ebp)
  801690:	ff 75 0c             	pushl  0xc(%ebp)
  801693:	50                   	push   %eax
  801694:	ff d2                	call   *%edx
  801696:	83 c4 10             	add    $0x10,%esp
}
  801699:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  80169c:	c9                   	leave  
  80169d:	c3                   	ret    
		cprintf("[%08x] write %d -- bad mode\n", thisenv->env_id, fdnum);
  80169e:	a1 04 50 80 00       	mov    0x805004,%eax
  8016a3:	8b 40 48             	mov    0x48(%eax),%eax
  8016a6:	83 ec 04             	sub    $0x4,%esp
  8016a9:	53                   	push   %ebx
  8016aa:	50                   	push   %eax
  8016ab:	68 19 30 80 00       	push   $0x803019
  8016b0:	e8 40 ec ff ff       	call   8002f5 <cprintf>
		return -E_INVAL;
  8016b5:	83 c4 10             	add    $0x10,%esp
  8016b8:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8016bd:	eb da                	jmp    801699 <write+0x59>
		return -E_NOT_SUPP;
  8016bf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8016c4:	eb d3                	jmp    801699 <write+0x59>

008016c6 <seek>:

int
seek(int fdnum, off_t offset)
{
  8016c6:	f3 0f 1e fb          	endbr32 
  8016ca:	55                   	push   %ebp
  8016cb:	89 e5                	mov    %esp,%ebp
  8016cd:	83 ec 20             	sub    $0x20,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8016d0:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8016d3:	50                   	push   %eax
  8016d4:	ff 75 08             	pushl  0x8(%ebp)
  8016d7:	e8 0b fc ff ff       	call   8012e7 <fd_lookup>
  8016dc:	83 c4 10             	add    $0x10,%esp
  8016df:	85 c0                	test   %eax,%eax
  8016e1:	78 0e                	js     8016f1 <seek+0x2b>
		return r;
	fd->fd_offset = offset;
  8016e3:	8b 55 0c             	mov    0xc(%ebp),%edx
  8016e6:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8016e9:	89 50 04             	mov    %edx,0x4(%eax)
	return 0;
  8016ec:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8016f1:	c9                   	leave  
  8016f2:	c3                   	ret    

008016f3 <ftruncate>:

int
ftruncate(int fdnum, off_t newsize)
{
  8016f3:	f3 0f 1e fb          	endbr32 
  8016f7:	55                   	push   %ebp
  8016f8:	89 e5                	mov    %esp,%ebp
  8016fa:	53                   	push   %ebx
  8016fb:	83 ec 1c             	sub    $0x1c,%esp
  8016fe:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801701:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801704:	50                   	push   %eax
  801705:	53                   	push   %ebx
  801706:	e8 dc fb ff ff       	call   8012e7 <fd_lookup>
  80170b:	83 c4 10             	add    $0x10,%esp
  80170e:	85 c0                	test   %eax,%eax
  801710:	78 37                	js     801749 <ftruncate+0x56>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801712:	83 ec 08             	sub    $0x8,%esp
  801715:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801718:	50                   	push   %eax
  801719:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80171c:	ff 30                	pushl  (%eax)
  80171e:	e8 18 fc ff ff       	call   80133b <dev_lookup>
  801723:	83 c4 10             	add    $0x10,%esp
  801726:	85 c0                	test   %eax,%eax
  801728:	78 1f                	js     801749 <ftruncate+0x56>
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80172a:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80172d:	f6 40 08 03          	testb  $0x3,0x8(%eax)
  801731:	74 1b                	je     80174e <ftruncate+0x5b>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			thisenv->env_id, fdnum);
		return -E_INVAL;
	}
	if (!dev->dev_trunc)
  801733:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801736:	8b 52 18             	mov    0x18(%edx),%edx
  801739:	85 d2                	test   %edx,%edx
  80173b:	74 32                	je     80176f <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  80173d:	83 ec 08             	sub    $0x8,%esp
  801740:	ff 75 0c             	pushl  0xc(%ebp)
  801743:	50                   	push   %eax
  801744:	ff d2                	call   *%edx
  801746:	83 c4 10             	add    $0x10,%esp
}
  801749:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  80174c:	c9                   	leave  
  80174d:	c3                   	ret    
			thisenv->env_id, fdnum);
  80174e:	a1 04 50 80 00       	mov    0x805004,%eax
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  801753:	8b 40 48             	mov    0x48(%eax),%eax
  801756:	83 ec 04             	sub    $0x4,%esp
  801759:	53                   	push   %ebx
  80175a:	50                   	push   %eax
  80175b:	68 dc 2f 80 00       	push   $0x802fdc
  801760:	e8 90 eb ff ff       	call   8002f5 <cprintf>
		return -E_INVAL;
  801765:	83 c4 10             	add    $0x10,%esp
  801768:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80176d:	eb da                	jmp    801749 <ftruncate+0x56>
		return -E_NOT_SUPP;
  80176f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801774:	eb d3                	jmp    801749 <ftruncate+0x56>

00801776 <fstat>:

int
fstat(int fdnum, struct Stat *stat)
{
  801776:	f3 0f 1e fb          	endbr32 
  80177a:	55                   	push   %ebp
  80177b:	89 e5                	mov    %esp,%ebp
  80177d:	53                   	push   %ebx
  80177e:	83 ec 1c             	sub    $0x1c,%esp
  801781:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801784:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801787:	50                   	push   %eax
  801788:	ff 75 08             	pushl  0x8(%ebp)
  80178b:	e8 57 fb ff ff       	call   8012e7 <fd_lookup>
  801790:	83 c4 10             	add    $0x10,%esp
  801793:	85 c0                	test   %eax,%eax
  801795:	78 4b                	js     8017e2 <fstat+0x6c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801797:	83 ec 08             	sub    $0x8,%esp
  80179a:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80179d:	50                   	push   %eax
  80179e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8017a1:	ff 30                	pushl  (%eax)
  8017a3:	e8 93 fb ff ff       	call   80133b <dev_lookup>
  8017a8:	83 c4 10             	add    $0x10,%esp
  8017ab:	85 c0                	test   %eax,%eax
  8017ad:	78 33                	js     8017e2 <fstat+0x6c>
		return r;
	if (!dev->dev_stat)
  8017af:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8017b2:	83 78 14 00          	cmpl   $0x0,0x14(%eax)
  8017b6:	74 2f                	je     8017e7 <fstat+0x71>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8017b8:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8017bb:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8017c2:	00 00 00 
	stat->st_isdir = 0;
  8017c5:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8017cc:	00 00 00 
	stat->st_dev = dev;
  8017cf:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  8017d5:	83 ec 08             	sub    $0x8,%esp
  8017d8:	53                   	push   %ebx
  8017d9:	ff 75 f0             	pushl  -0x10(%ebp)
  8017dc:	ff 50 14             	call   *0x14(%eax)
  8017df:	83 c4 10             	add    $0x10,%esp
}
  8017e2:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  8017e5:	c9                   	leave  
  8017e6:	c3                   	ret    
		return -E_NOT_SUPP;
  8017e7:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8017ec:	eb f4                	jmp    8017e2 <fstat+0x6c>

008017ee <stat>:

int
stat(const char *path, struct Stat *stat)
{
  8017ee:	f3 0f 1e fb          	endbr32 
  8017f2:	55                   	push   %ebp
  8017f3:	89 e5                	mov    %esp,%ebp
  8017f5:	56                   	push   %esi
  8017f6:	53                   	push   %ebx
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  8017f7:	83 ec 08             	sub    $0x8,%esp
  8017fa:	6a 00                	push   $0x0
  8017fc:	ff 75 08             	pushl  0x8(%ebp)
  8017ff:	e8 fb 01 00 00       	call   8019ff <open>
  801804:	89 c3                	mov    %eax,%ebx
  801806:	83 c4 10             	add    $0x10,%esp
  801809:	85 c0                	test   %eax,%eax
  80180b:	78 1b                	js     801828 <stat+0x3a>
		return fd;
	r = fstat(fd, stat);
  80180d:	83 ec 08             	sub    $0x8,%esp
  801810:	ff 75 0c             	pushl  0xc(%ebp)
  801813:	50                   	push   %eax
  801814:	e8 5d ff ff ff       	call   801776 <fstat>
  801819:	89 c6                	mov    %eax,%esi
	close(fd);
  80181b:	89 1c 24             	mov    %ebx,(%esp)
  80181e:	e8 fd fb ff ff       	call   801420 <close>
	return r;
  801823:	83 c4 10             	add    $0x10,%esp
  801826:	89 f3                	mov    %esi,%ebx
}
  801828:	89 d8                	mov    %ebx,%eax
  80182a:	8d 65 f8             	lea    -0x8(%ebp),%esp
  80182d:	5b                   	pop    %ebx
  80182e:	5e                   	pop    %esi
  80182f:	5d                   	pop    %ebp
  801830:	c3                   	ret    

00801831 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801831:	55                   	push   %ebp
  801832:	89 e5                	mov    %esp,%ebp
  801834:	56                   	push   %esi
  801835:	53                   	push   %ebx
  801836:	89 c6                	mov    %eax,%esi
  801838:	89 d3                	mov    %edx,%ebx
	static envid_t fsenv;
	if (fsenv == 0)
  80183a:	83 3d 00 50 80 00 00 	cmpl   $0x0,0x805000
  801841:	74 27                	je     80186a <fsipc+0x39>
	static_assert(sizeof(fsipcbuf) == PGSIZE);

	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", thisenv->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(fsenv, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801843:	6a 07                	push   $0x7
  801845:	68 00 60 80 00       	push   $0x806000
  80184a:	56                   	push   %esi
  80184b:	ff 35 00 50 80 00    	pushl  0x805000
  801851:	e8 d2 0e 00 00       	call   802728 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801856:	83 c4 0c             	add    $0xc,%esp
  801859:	6a 00                	push   $0x0
  80185b:	53                   	push   %ebx
  80185c:	6a 00                	push   $0x0
  80185e:	e8 44 0e 00 00       	call   8026a7 <ipc_recv>
}
  801863:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801866:	5b                   	pop    %ebx
  801867:	5e                   	pop    %esi
  801868:	5d                   	pop    %ebp
  801869:	c3                   	ret    
		fsenv = ipc_find_env(ENV_TYPE_FS);
  80186a:	83 ec 0c             	sub    $0xc,%esp
  80186d:	6a 01                	push   $0x1
  80186f:	e8 0c 0f 00 00       	call   802780 <ipc_find_env>
  801874:	a3 00 50 80 00       	mov    %eax,0x805000
  801879:	83 c4 10             	add    $0x10,%esp
  80187c:	eb c5                	jmp    801843 <fsipc+0x12>

0080187e <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  80187e:	f3 0f 1e fb          	endbr32 
  801882:	55                   	push   %ebp
  801883:	89 e5                	mov    %esp,%ebp
  801885:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801888:	8b 45 08             	mov    0x8(%ebp),%eax
  80188b:	8b 40 0c             	mov    0xc(%eax),%eax
  80188e:	a3 00 60 80 00       	mov    %eax,0x806000
	fsipcbuf.set_size.req_size = newsize;
  801893:	8b 45 0c             	mov    0xc(%ebp),%eax
  801896:	a3 04 60 80 00       	mov    %eax,0x806004
	return fsipc(FSREQ_SET_SIZE, NULL);
  80189b:	ba 00 00 00 00       	mov    $0x0,%edx
  8018a0:	b8 02 00 00 00       	mov    $0x2,%eax
  8018a5:	e8 87 ff ff ff       	call   801831 <fsipc>
}
  8018aa:	c9                   	leave  
  8018ab:	c3                   	ret    

008018ac <devfile_flush>:
{
  8018ac:	f3 0f 1e fb          	endbr32 
  8018b0:	55                   	push   %ebp
  8018b1:	89 e5                	mov    %esp,%ebp
  8018b3:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  8018b6:	8b 45 08             	mov    0x8(%ebp),%eax
  8018b9:	8b 40 0c             	mov    0xc(%eax),%eax
  8018bc:	a3 00 60 80 00       	mov    %eax,0x806000
	return fsipc(FSREQ_FLUSH, NULL);
  8018c1:	ba 00 00 00 00       	mov    $0x0,%edx
  8018c6:	b8 06 00 00 00       	mov    $0x6,%eax
  8018cb:	e8 61 ff ff ff       	call   801831 <fsipc>
}
  8018d0:	c9                   	leave  
  8018d1:	c3                   	ret    

008018d2 <devfile_stat>:
{
  8018d2:	f3 0f 1e fb          	endbr32 
  8018d6:	55                   	push   %ebp
  8018d7:	89 e5                	mov    %esp,%ebp
  8018d9:	53                   	push   %ebx
  8018da:	83 ec 04             	sub    $0x4,%esp
  8018dd:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  8018e0:	8b 45 08             	mov    0x8(%ebp),%eax
  8018e3:	8b 40 0c             	mov    0xc(%eax),%eax
  8018e6:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  8018eb:	ba 00 00 00 00       	mov    $0x0,%edx
  8018f0:	b8 05 00 00 00       	mov    $0x5,%eax
  8018f5:	e8 37 ff ff ff       	call   801831 <fsipc>
  8018fa:	85 c0                	test   %eax,%eax
  8018fc:	78 2c                	js     80192a <devfile_stat+0x58>
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  8018fe:	83 ec 08             	sub    $0x8,%esp
  801901:	68 00 60 80 00       	push   $0x806000
  801906:	53                   	push   %ebx
  801907:	e8 c2 ef ff ff       	call   8008ce <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  80190c:	a1 80 60 80 00       	mov    0x806080,%eax
  801911:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801917:	a1 84 60 80 00       	mov    0x806084,%eax
  80191c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
	return 0;
  801922:	83 c4 10             	add    $0x10,%esp
  801925:	b8 00 00 00 00       	mov    $0x0,%eax
}
  80192a:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  80192d:	c9                   	leave  
  80192e:	c3                   	ret    

0080192f <devfile_write>:
{
  80192f:	f3 0f 1e fb          	endbr32 
  801933:	55                   	push   %ebp
  801934:	89 e5                	mov    %esp,%ebp
  801936:	83 ec 0c             	sub    $0xc,%esp
  801939:	8b 45 10             	mov    0x10(%ebp),%eax
  80193c:	3d f8 0f 00 00       	cmp    $0xff8,%eax
  801941:	ba f8 0f 00 00       	mov    $0xff8,%edx
  801946:	0f 47 c2             	cmova  %edx,%eax
	fsipcbuf.write.req_fileid = fd->fd_file.id;
  801949:	8b 55 08             	mov    0x8(%ebp),%edx
  80194c:	8b 52 0c             	mov    0xc(%edx),%edx
  80194f:	89 15 00 60 80 00    	mov    %edx,0x806000
	fsipcbuf.write.req_n = n;
  801955:	a3 04 60 80 00       	mov    %eax,0x806004
	memmove(fsipcbuf.write.req_buf, buf, n);
  80195a:	50                   	push   %eax
  80195b:	ff 75 0c             	pushl  0xc(%ebp)
  80195e:	68 08 60 80 00       	push   $0x806008
  801963:	e8 1c f1 ff ff       	call   800a84 <memmove>
	return fsipc(FSREQ_WRITE, NULL);}
  801968:	ba 00 00 00 00       	mov    $0x0,%edx
  80196d:	b8 04 00 00 00       	mov    $0x4,%eax
  801972:	e8 ba fe ff ff       	call   801831 <fsipc>
  801977:	c9                   	leave  
  801978:	c3                   	ret    

00801979 <devfile_read>:
{
  801979:	f3 0f 1e fb          	endbr32 
  80197d:	55                   	push   %ebp
  80197e:	89 e5                	mov    %esp,%ebp
  801980:	56                   	push   %esi
  801981:	53                   	push   %ebx
  801982:	8b 75 10             	mov    0x10(%ebp),%esi
	fsipcbuf.read.req_fileid = fd->fd_file.id;
  801985:	8b 45 08             	mov    0x8(%ebp),%eax
  801988:	8b 40 0c             	mov    0xc(%eax),%eax
  80198b:	a3 00 60 80 00       	mov    %eax,0x806000
	fsipcbuf.read.req_n = n;
  801990:	89 35 04 60 80 00    	mov    %esi,0x806004
	if ((r = fsipc(FSREQ_READ, NULL)) < 0)
  801996:	ba 00 00 00 00       	mov    $0x0,%edx
  80199b:	b8 03 00 00 00       	mov    $0x3,%eax
  8019a0:	e8 8c fe ff ff       	call   801831 <fsipc>
  8019a5:	89 c3                	mov    %eax,%ebx
  8019a7:	85 c0                	test   %eax,%eax
  8019a9:	78 1f                	js     8019ca <devfile_read+0x51>
	assert(r <= n);
  8019ab:	39 f0                	cmp    %esi,%eax
  8019ad:	77 24                	ja     8019d3 <devfile_read+0x5a>
	assert(r <= PGSIZE);
  8019af:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8019b4:	7f 33                	jg     8019e9 <devfile_read+0x70>
	memmove(buf, fsipcbuf.readRet.ret_buf, r);
  8019b6:	83 ec 04             	sub    $0x4,%esp
  8019b9:	50                   	push   %eax
  8019ba:	68 00 60 80 00       	push   $0x806000
  8019bf:	ff 75 0c             	pushl  0xc(%ebp)
  8019c2:	e8 bd f0 ff ff       	call   800a84 <memmove>
	return r;
  8019c7:	83 c4 10             	add    $0x10,%esp
}
  8019ca:	89 d8                	mov    %ebx,%eax
  8019cc:	8d 65 f8             	lea    -0x8(%ebp),%esp
  8019cf:	5b                   	pop    %ebx
  8019d0:	5e                   	pop    %esi
  8019d1:	5d                   	pop    %ebp
  8019d2:	c3                   	ret    
	assert(r <= n);
  8019d3:	68 48 30 80 00       	push   $0x803048
  8019d8:	68 4f 30 80 00       	push   $0x80304f
  8019dd:	6a 7c                	push   $0x7c
  8019df:	68 64 30 80 00       	push   $0x803064
  8019e4:	e8 25 e8 ff ff       	call   80020e <_panic>
	assert(r <= PGSIZE);
  8019e9:	68 6f 30 80 00       	push   $0x80306f
  8019ee:	68 4f 30 80 00       	push   $0x80304f
  8019f3:	6a 7d                	push   $0x7d
  8019f5:	68 64 30 80 00       	push   $0x803064
  8019fa:	e8 0f e8 ff ff       	call   80020e <_panic>

008019ff <open>:
{
  8019ff:	f3 0f 1e fb          	endbr32 
  801a03:	55                   	push   %ebp
  801a04:	89 e5                	mov    %esp,%ebp
  801a06:	56                   	push   %esi
  801a07:	53                   	push   %ebx
  801a08:	83 ec 1c             	sub    $0x1c,%esp
  801a0b:	8b 75 08             	mov    0x8(%ebp),%esi
	if (strlen(path) >= MAXPATHLEN)
  801a0e:	56                   	push   %esi
  801a0f:	e8 77 ee ff ff       	call   80088b <strlen>
  801a14:	83 c4 10             	add    $0x10,%esp
  801a17:	3d ff 03 00 00       	cmp    $0x3ff,%eax
  801a1c:	7f 6c                	jg     801a8a <open+0x8b>
	if ((r = fd_alloc(&fd)) < 0)
  801a1e:	83 ec 0c             	sub    $0xc,%esp
  801a21:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a24:	50                   	push   %eax
  801a25:	e8 67 f8 ff ff       	call   801291 <fd_alloc>
  801a2a:	89 c3                	mov    %eax,%ebx
  801a2c:	83 c4 10             	add    $0x10,%esp
  801a2f:	85 c0                	test   %eax,%eax
  801a31:	78 3c                	js     801a6f <open+0x70>
	strcpy(fsipcbuf.open.req_path, path);
  801a33:	83 ec 08             	sub    $0x8,%esp
  801a36:	56                   	push   %esi
  801a37:	68 00 60 80 00       	push   $0x806000
  801a3c:	e8 8d ee ff ff       	call   8008ce <strcpy>
	fsipcbuf.open.req_omode = mode;
  801a41:	8b 45 0c             	mov    0xc(%ebp),%eax
  801a44:	a3 00 64 80 00       	mov    %eax,0x806400
	if ((r = fsipc(FSREQ_OPEN, fd)) < 0) {
  801a49:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801a4c:	b8 01 00 00 00       	mov    $0x1,%eax
  801a51:	e8 db fd ff ff       	call   801831 <fsipc>
  801a56:	89 c3                	mov    %eax,%ebx
  801a58:	83 c4 10             	add    $0x10,%esp
  801a5b:	85 c0                	test   %eax,%eax
  801a5d:	78 19                	js     801a78 <open+0x79>
	return fd2num(fd);
  801a5f:	83 ec 0c             	sub    $0xc,%esp
  801a62:	ff 75 f4             	pushl  -0xc(%ebp)
  801a65:	e8 f8 f7 ff ff       	call   801262 <fd2num>
  801a6a:	89 c3                	mov    %eax,%ebx
  801a6c:	83 c4 10             	add    $0x10,%esp
}
  801a6f:	89 d8                	mov    %ebx,%eax
  801a71:	8d 65 f8             	lea    -0x8(%ebp),%esp
  801a74:	5b                   	pop    %ebx
  801a75:	5e                   	pop    %esi
  801a76:	5d                   	pop    %ebp
  801a77:	c3                   	ret    
		fd_close(fd, 0);
  801a78:	83 ec 08             	sub    $0x8,%esp
  801a7b:	6a 00                	push   $0x0
  801a7d:	ff 75 f4             	pushl  -0xc(%ebp)
  801a80:	e8 10 f9 ff ff       	call   801395 <fd_close>
		return r;
  801a85:	83 c4 10             	add    $0x10,%esp
  801a88:	eb e5                	jmp    801a6f <open+0x70>
		return -E_BAD_PATH;
  801a8a:	bb f4 ff ff ff       	mov    $0xfffffff4,%ebx
  801a8f:	eb de                	jmp    801a6f <open+0x70>

00801a91 <sync>:


// Synchronize disk with buffer cache
int
sync(void)
{
  801a91:	f3 0f 1e fb          	endbr32 
  801a95:	55                   	push   %ebp
  801a96:	89 e5                	mov    %esp,%ebp
  801a98:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801a9b:	ba 00 00 00 00       	mov    $0x0,%edx
  801aa0:	b8 08 00 00 00       	mov    $0x8,%eax
  801aa5:	e8 87 fd ff ff       	call   801831 <fsipc>
}
  801aaa:	c9                   	leave  
  801aab:	c3                   	ret    

00801aac <spawn>:
// argv: pointer to null-terminated array of pointers to strings,
// 	 which will be passed to the child as its command-line arguments.
// Returns child envid on success, < 0 on failure.
int
spawn(const char *prog, const char **argv)
{
  801aac:	f3 0f 1e fb          	endbr32 
  801ab0:	55                   	push   %ebp
  801ab1:	89 e5                	mov    %esp,%ebp
  801ab3:	57                   	push   %edi
  801ab4:	56                   	push   %esi
  801ab5:	53                   	push   %ebx
  801ab6:	81 ec 94 02 00 00    	sub    $0x294,%esp
	//   - Call sys_env_set_trapframe(child, &child_tf) to set up the
	//     correct initial eip and esp values in the child.
	//
	//   - Start the child process running with sys_env_set_status().

	if ((r = open(prog, O_RDONLY)) < 0)
  801abc:	6a 00                	push   $0x0
  801abe:	ff 75 08             	pushl  0x8(%ebp)
  801ac1:	e8 39 ff ff ff       	call   8019ff <open>
  801ac6:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  801acc:	83 c4 10             	add    $0x10,%esp
  801acf:	85 c0                	test   %eax,%eax
  801ad1:	0f 88 e5 04 00 00    	js     801fbc <spawn+0x510>
  801ad7:	89 c1                	mov    %eax,%ecx
		return r;
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (readn(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
  801ad9:	83 ec 04             	sub    $0x4,%esp
  801adc:	68 00 02 00 00       	push   $0x200
  801ae1:	8d 85 e8 fd ff ff    	lea    -0x218(%ebp),%eax
  801ae7:	50                   	push   %eax
  801ae8:	51                   	push   %ecx
  801ae9:	e8 07 fb ff ff       	call   8015f5 <readn>
  801aee:	83 c4 10             	add    $0x10,%esp
  801af1:	3d 00 02 00 00       	cmp    $0x200,%eax
  801af6:	75 7e                	jne    801b76 <spawn+0xca>
	    || elf->e_magic != ELF_MAGIC) {
  801af8:	81 bd e8 fd ff ff 7f 	cmpl   $0x464c457f,-0x218(%ebp)
  801aff:	45 4c 46 
  801b02:	75 72                	jne    801b76 <spawn+0xca>
  801b04:	b8 07 00 00 00       	mov    $0x7,%eax
  801b09:	cd 30                	int    $0x30
  801b0b:	89 85 74 fd ff ff    	mov    %eax,-0x28c(%ebp)
  801b11:	89 85 88 fd ff ff    	mov    %eax,-0x278(%ebp)
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
		return -E_NOT_EXEC;
	}

	// Create new child environment
	if ((r = sys_exofork()) < 0)
  801b17:	85 c0                	test   %eax,%eax
  801b19:	0f 88 91 04 00 00    	js     801fb0 <spawn+0x504>
		return r;
	child = r;

	// Set up trap frame, including initial stack.
	child_tf = envs[ENVX(child)].env_tf;
  801b1f:	25 ff 03 00 00       	and    $0x3ff,%eax
  801b24:	6b f0 7c             	imul   $0x7c,%eax,%esi
  801b27:	81 c6 00 00 c0 ee    	add    $0xeec00000,%esi
  801b2d:	8d bd a4 fd ff ff    	lea    -0x25c(%ebp),%edi
  801b33:	b9 11 00 00 00       	mov    $0x11,%ecx
  801b38:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	child_tf.tf_eip = elf->e_entry;
  801b3a:	8b 85 00 fe ff ff    	mov    -0x200(%ebp),%eax
  801b40:	89 85 d4 fd ff ff    	mov    %eax,-0x22c(%ebp)
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  801b46:	bb 00 00 00 00       	mov    $0x0,%ebx
	string_size = 0;
  801b4b:	be 00 00 00 00       	mov    $0x0,%esi
  801b50:	8b 7d 0c             	mov    0xc(%ebp),%edi
  801b53:	8d 0c 9d 00 00 00 00 	lea    0x0(,%ebx,4),%ecx
	for (argc = 0; argv[argc] != 0; argc++)
  801b5a:	8b 04 9f             	mov    (%edi,%ebx,4),%eax
  801b5d:	85 c0                	test   %eax,%eax
  801b5f:	74 4d                	je     801bae <spawn+0x102>
		string_size += strlen(argv[argc]) + 1;
  801b61:	83 ec 0c             	sub    $0xc,%esp
  801b64:	50                   	push   %eax
  801b65:	e8 21 ed ff ff       	call   80088b <strlen>
  801b6a:	8d 74 06 01          	lea    0x1(%esi,%eax,1),%esi
	for (argc = 0; argv[argc] != 0; argc++)
  801b6e:	83 c3 01             	add    $0x1,%ebx
  801b71:	83 c4 10             	add    $0x10,%esp
  801b74:	eb dd                	jmp    801b53 <spawn+0xa7>
		close(fd);
  801b76:	83 ec 0c             	sub    $0xc,%esp
  801b79:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  801b7f:	e8 9c f8 ff ff       	call   801420 <close>
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
  801b84:	83 c4 0c             	add    $0xc,%esp
  801b87:	68 7f 45 4c 46       	push   $0x464c457f
  801b8c:	ff b5 e8 fd ff ff    	pushl  -0x218(%ebp)
  801b92:	68 7b 30 80 00       	push   $0x80307b
  801b97:	e8 59 e7 ff ff       	call   8002f5 <cprintf>
		return -E_NOT_EXEC;
  801b9c:	83 c4 10             	add    $0x10,%esp
  801b9f:	c7 85 94 fd ff ff f2 	movl   $0xfffffff2,-0x26c(%ebp)
  801ba6:	ff ff ff 
  801ba9:	e9 0e 04 00 00       	jmp    801fbc <spawn+0x510>
  801bae:	89 9d 84 fd ff ff    	mov    %ebx,-0x27c(%ebp)
  801bb4:	89 8d 80 fd ff ff    	mov    %ecx,-0x280(%ebp)
	// Determine where to place the strings and the argv array.
	// Set up pointers into the temporary page 'UTEMP'; we'll map a page
	// there later, then remap that page into the child environment
	// at (USTACKTOP - PGSIZE).
	// strings is the topmost thing on the stack.
	string_store = (char*) UTEMP + PGSIZE - string_size;
  801bba:	bf 00 10 40 00       	mov    $0x401000,%edi
  801bbf:	29 f7                	sub    %esi,%edi
	// argv is below that.  There's one argument pointer per argument, plus
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
  801bc1:	89 fa                	mov    %edi,%edx
  801bc3:	83 e2 fc             	and    $0xfffffffc,%edx
  801bc6:	8d 04 9d 04 00 00 00 	lea    0x4(,%ebx,4),%eax
  801bcd:	29 c2                	sub    %eax,%edx
  801bcf:	89 95 90 fd ff ff    	mov    %edx,-0x270(%ebp)

	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  801bd5:	8d 42 f8             	lea    -0x8(%edx),%eax
  801bd8:	3d ff ff 3f 00       	cmp    $0x3fffff,%eax
  801bdd:	0f 86 fc 03 00 00    	jbe    801fdf <spawn+0x533>
		return -E_NO_MEM;

	// Allocate the single stack page at UTEMP.
	if ((r = sys_page_alloc(0, (void*) UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  801be3:	83 ec 04             	sub    $0x4,%esp
  801be6:	6a 07                	push   $0x7
  801be8:	68 00 00 40 00       	push   $0x400000
  801bed:	6a 00                	push   $0x0
  801bef:	e8 1c f1 ff ff       	call   800d10 <sys_page_alloc>
  801bf4:	83 c4 10             	add    $0x10,%esp
  801bf7:	85 c0                	test   %eax,%eax
  801bf9:	0f 88 e5 03 00 00    	js     801fe4 <spawn+0x538>
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  801bff:	be 00 00 00 00       	mov    $0x0,%esi
  801c04:	89 9d 8c fd ff ff    	mov    %ebx,-0x274(%ebp)
  801c0a:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  801c0d:	eb 30                	jmp    801c3f <spawn+0x193>
		argv_store[i] = UTEMP2USTACK(string_store);
  801c0f:	8d 87 00 d0 7f ee    	lea    -0x11803000(%edi),%eax
  801c15:	8b 8d 90 fd ff ff    	mov    -0x270(%ebp),%ecx
  801c1b:	89 04 b1             	mov    %eax,(%ecx,%esi,4)
		strcpy(string_store, argv[i]);
  801c1e:	83 ec 08             	sub    $0x8,%esp
  801c21:	ff 34 b3             	pushl  (%ebx,%esi,4)
  801c24:	57                   	push   %edi
  801c25:	e8 a4 ec ff ff       	call   8008ce <strcpy>
		string_store += strlen(argv[i]) + 1;
  801c2a:	83 c4 04             	add    $0x4,%esp
  801c2d:	ff 34 b3             	pushl  (%ebx,%esi,4)
  801c30:	e8 56 ec ff ff       	call   80088b <strlen>
  801c35:	8d 7c 07 01          	lea    0x1(%edi,%eax,1),%edi
	for (i = 0; i < argc; i++) {
  801c39:	83 c6 01             	add    $0x1,%esi
  801c3c:	83 c4 10             	add    $0x10,%esp
  801c3f:	39 b5 8c fd ff ff    	cmp    %esi,-0x274(%ebp)
  801c45:	7f c8                	jg     801c0f <spawn+0x163>
	}
	argv_store[argc] = 0;
  801c47:	8b 85 90 fd ff ff    	mov    -0x270(%ebp),%eax
  801c4d:	8b 8d 80 fd ff ff    	mov    -0x280(%ebp),%ecx
  801c53:	c7 04 08 00 00 00 00 	movl   $0x0,(%eax,%ecx,1)
	assert(string_store == (char*)UTEMP + PGSIZE);
  801c5a:	81 ff 00 10 40 00    	cmp    $0x401000,%edi
  801c60:	0f 85 86 00 00 00    	jne    801cec <spawn+0x240>

	argv_store[-1] = UTEMP2USTACK(argv_store);
  801c66:	8b 95 90 fd ff ff    	mov    -0x270(%ebp),%edx
  801c6c:	8d 82 00 d0 7f ee    	lea    -0x11803000(%edx),%eax
  801c72:	89 42 fc             	mov    %eax,-0x4(%edx)
	argv_store[-2] = argc;
  801c75:	89 d0                	mov    %edx,%eax
  801c77:	8b 8d 84 fd ff ff    	mov    -0x27c(%ebp),%ecx
  801c7d:	89 4a f8             	mov    %ecx,-0x8(%edx)

	*init_esp = UTEMP2USTACK(&argv_store[-2]);
  801c80:	2d 08 30 80 11       	sub    $0x11803008,%eax
  801c85:	89 85 e0 fd ff ff    	mov    %eax,-0x220(%ebp)

	// After completing the stack, map it into the child's address space
	// and unmap it from ours!
	if ((r = sys_page_map(0, UTEMP, child, (void*) (USTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0)
  801c8b:	83 ec 0c             	sub    $0xc,%esp
  801c8e:	6a 07                	push   $0x7
  801c90:	68 00 d0 bf ee       	push   $0xeebfd000
  801c95:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  801c9b:	68 00 00 40 00       	push   $0x400000
  801ca0:	6a 00                	push   $0x0
  801ca2:	e8 b0 f0 ff ff       	call   800d57 <sys_page_map>
  801ca7:	89 c3                	mov    %eax,%ebx
  801ca9:	83 c4 20             	add    $0x20,%esp
  801cac:	85 c0                	test   %eax,%eax
  801cae:	0f 88 38 03 00 00    	js     801fec <spawn+0x540>
		goto error;
	if ((r = sys_page_unmap(0, UTEMP)) < 0)
  801cb4:	83 ec 08             	sub    $0x8,%esp
  801cb7:	68 00 00 40 00       	push   $0x400000
  801cbc:	6a 00                	push   $0x0
  801cbe:	e8 da f0 ff ff       	call   800d9d <sys_page_unmap>
  801cc3:	89 c3                	mov    %eax,%ebx
  801cc5:	83 c4 10             	add    $0x10,%esp
  801cc8:	85 c0                	test   %eax,%eax
  801cca:	0f 88 1c 03 00 00    	js     801fec <spawn+0x540>
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  801cd0:	8b 85 04 fe ff ff    	mov    -0x1fc(%ebp),%eax
  801cd6:	8d b4 05 e8 fd ff ff 	lea    -0x218(%ebp,%eax,1),%esi
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  801cdd:	c7 85 84 fd ff ff 00 	movl   $0x0,-0x27c(%ebp)
  801ce4:	00 00 00 
  801ce7:	e9 4f 01 00 00       	jmp    801e3b <spawn+0x38f>
	assert(string_store == (char*)UTEMP + PGSIZE);
  801cec:	68 f0 30 80 00       	push   $0x8030f0
  801cf1:	68 4f 30 80 00       	push   $0x80304f
  801cf6:	68 f2 00 00 00       	push   $0xf2
  801cfb:	68 95 30 80 00       	push   $0x803095
  801d00:	e8 09 e5 ff ff       	call   80020e <_panic>
			// allocate a blank page
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
				return r;
		} else {
			// from file
			if ((r = sys_page_alloc(0, UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  801d05:	83 ec 04             	sub    $0x4,%esp
  801d08:	6a 07                	push   $0x7
  801d0a:	68 00 00 40 00       	push   $0x400000
  801d0f:	6a 00                	push   $0x0
  801d11:	e8 fa ef ff ff       	call   800d10 <sys_page_alloc>
  801d16:	83 c4 10             	add    $0x10,%esp
  801d19:	85 c0                	test   %eax,%eax
  801d1b:	0f 88 a9 02 00 00    	js     801fca <spawn+0x51e>
				return r;
			if ((r = seek(fd, fileoffset + i)) < 0)
  801d21:	83 ec 08             	sub    $0x8,%esp
  801d24:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  801d2a:	01 f0                	add    %esi,%eax
  801d2c:	50                   	push   %eax
  801d2d:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  801d33:	e8 8e f9 ff ff       	call   8016c6 <seek>
  801d38:	83 c4 10             	add    $0x10,%esp
  801d3b:	85 c0                	test   %eax,%eax
  801d3d:	0f 88 8e 02 00 00    	js     801fd1 <spawn+0x525>
				return r;
			if ((r = readn(fd, UTEMP, MIN(PGSIZE, filesz-i))) < 0)
  801d43:	83 ec 04             	sub    $0x4,%esp
  801d46:	8b 85 90 fd ff ff    	mov    -0x270(%ebp),%eax
  801d4c:	29 f0                	sub    %esi,%eax
  801d4e:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801d53:	b9 00 10 00 00       	mov    $0x1000,%ecx
  801d58:	0f 47 c1             	cmova  %ecx,%eax
  801d5b:	50                   	push   %eax
  801d5c:	68 00 00 40 00       	push   $0x400000
  801d61:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  801d67:	e8 89 f8 ff ff       	call   8015f5 <readn>
  801d6c:	83 c4 10             	add    $0x10,%esp
  801d6f:	85 c0                	test   %eax,%eax
  801d71:	0f 88 61 02 00 00    	js     801fd8 <spawn+0x52c>
				return r;
			if ((r = sys_page_map(0, UTEMP, child, (void*) (va + i), perm)) < 0)
  801d77:	83 ec 0c             	sub    $0xc,%esp
  801d7a:	ff b5 8c fd ff ff    	pushl  -0x274(%ebp)
  801d80:	53                   	push   %ebx
  801d81:	ff b5 88 fd ff ff    	pushl  -0x278(%ebp)
  801d87:	68 00 00 40 00       	push   $0x400000
  801d8c:	6a 00                	push   $0x0
  801d8e:	e8 c4 ef ff ff       	call   800d57 <sys_page_map>
  801d93:	83 c4 20             	add    $0x20,%esp
  801d96:	85 c0                	test   %eax,%eax
  801d98:	78 7c                	js     801e16 <spawn+0x36a>
				panic("spawn: sys_page_map data: %e", r);
			sys_page_unmap(0, UTEMP);
  801d9a:	83 ec 08             	sub    $0x8,%esp
  801d9d:	68 00 00 40 00       	push   $0x400000
  801da2:	6a 00                	push   $0x0
  801da4:	e8 f4 ef ff ff       	call   800d9d <sys_page_unmap>
  801da9:	83 c4 10             	add    $0x10,%esp
	for (i = 0; i < memsz; i += PGSIZE) {
  801dac:	81 c7 00 10 00 00    	add    $0x1000,%edi
  801db2:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  801db8:	89 fe                	mov    %edi,%esi
  801dba:	39 bd 7c fd ff ff    	cmp    %edi,-0x284(%ebp)
  801dc0:	76 69                	jbe    801e2b <spawn+0x37f>
		if (i >= filesz) {
  801dc2:	39 bd 90 fd ff ff    	cmp    %edi,-0x270(%ebp)
  801dc8:	0f 87 37 ff ff ff    	ja     801d05 <spawn+0x259>
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
  801dce:	83 ec 04             	sub    $0x4,%esp
  801dd1:	ff b5 8c fd ff ff    	pushl  -0x274(%ebp)
  801dd7:	53                   	push   %ebx
  801dd8:	ff b5 88 fd ff ff    	pushl  -0x278(%ebp)
  801dde:	e8 2d ef ff ff       	call   800d10 <sys_page_alloc>
  801de3:	83 c4 10             	add    $0x10,%esp
  801de6:	85 c0                	test   %eax,%eax
  801de8:	79 c2                	jns    801dac <spawn+0x300>
  801dea:	89 c7                	mov    %eax,%edi
	sys_env_destroy(child);
  801dec:	83 ec 0c             	sub    $0xc,%esp
  801def:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  801df5:	e8 8b ee ff ff       	call   800c85 <sys_env_destroy>
	close(fd);
  801dfa:	83 c4 04             	add    $0x4,%esp
  801dfd:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  801e03:	e8 18 f6 ff ff       	call   801420 <close>
	return r;
  801e08:	83 c4 10             	add    $0x10,%esp
  801e0b:	89 bd 94 fd ff ff    	mov    %edi,-0x26c(%ebp)
  801e11:	e9 a6 01 00 00       	jmp    801fbc <spawn+0x510>
				panic("spawn: sys_page_map data: %e", r);
  801e16:	50                   	push   %eax
  801e17:	68 a1 30 80 00       	push   $0x8030a1
  801e1c:	68 25 01 00 00       	push   $0x125
  801e21:	68 95 30 80 00       	push   $0x803095
  801e26:	e8 e3 e3 ff ff       	call   80020e <_panic>
  801e2b:	8b b5 78 fd ff ff    	mov    -0x288(%ebp),%esi
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  801e31:	83 85 84 fd ff ff 01 	addl   $0x1,-0x27c(%ebp)
  801e38:	83 c6 20             	add    $0x20,%esi
  801e3b:	0f b7 85 14 fe ff ff 	movzwl -0x1ec(%ebp),%eax
  801e42:	3b 85 84 fd ff ff    	cmp    -0x27c(%ebp),%eax
  801e48:	7e 6d                	jle    801eb7 <spawn+0x40b>
		if (ph->p_type != ELF_PROG_LOAD)
  801e4a:	83 3e 01             	cmpl   $0x1,(%esi)
  801e4d:	75 e2                	jne    801e31 <spawn+0x385>
		if (ph->p_flags & ELF_PROG_FLAG_WRITE)
  801e4f:	8b 46 18             	mov    0x18(%esi),%eax
  801e52:	83 e0 02             	and    $0x2,%eax
			perm |= PTE_W;
  801e55:	83 f8 01             	cmp    $0x1,%eax
  801e58:	19 c0                	sbb    %eax,%eax
  801e5a:	83 e0 fe             	and    $0xfffffffe,%eax
  801e5d:	83 c0 07             	add    $0x7,%eax
  801e60:	89 85 8c fd ff ff    	mov    %eax,-0x274(%ebp)
		if ((r = map_segment(child, ph->p_va, ph->p_memsz,
  801e66:	8b 4e 04             	mov    0x4(%esi),%ecx
  801e69:	89 8d 80 fd ff ff    	mov    %ecx,-0x280(%ebp)
  801e6f:	8b 56 10             	mov    0x10(%esi),%edx
  801e72:	89 95 90 fd ff ff    	mov    %edx,-0x270(%ebp)
  801e78:	8b 7e 14             	mov    0x14(%esi),%edi
  801e7b:	89 bd 7c fd ff ff    	mov    %edi,-0x284(%ebp)
  801e81:	8b 5e 08             	mov    0x8(%esi),%ebx
	if ((i = PGOFF(va))) {
  801e84:	89 d8                	mov    %ebx,%eax
  801e86:	25 ff 0f 00 00       	and    $0xfff,%eax
  801e8b:	74 1a                	je     801ea7 <spawn+0x3fb>
		va -= i;
  801e8d:	29 c3                	sub    %eax,%ebx
		memsz += i;
  801e8f:	01 c7                	add    %eax,%edi
  801e91:	89 bd 7c fd ff ff    	mov    %edi,-0x284(%ebp)
		filesz += i;
  801e97:	01 c2                	add    %eax,%edx
  801e99:	89 95 90 fd ff ff    	mov    %edx,-0x270(%ebp)
		fileoffset -= i;
  801e9f:	29 c1                	sub    %eax,%ecx
  801ea1:	89 8d 80 fd ff ff    	mov    %ecx,-0x280(%ebp)
	for (i = 0; i < memsz; i += PGSIZE) {
  801ea7:	bf 00 00 00 00       	mov    $0x0,%edi
  801eac:	89 b5 78 fd ff ff    	mov    %esi,-0x288(%ebp)
  801eb2:	e9 01 ff ff ff       	jmp    801db8 <spawn+0x30c>
	close(fd);
  801eb7:	83 ec 0c             	sub    $0xc,%esp
  801eba:	ff b5 94 fd ff ff    	pushl  -0x26c(%ebp)
  801ec0:	e8 5b f5 ff ff       	call   801420 <close>
  801ec5:	83 c4 10             	add    $0x10,%esp
static int
copy_shared_pages(envid_t child)
{
	// LAB 5: Your code here.
	uintptr_t addr;
	for (addr = 0; addr < UTOP; addr += PGSIZE) {
  801ec8:	bb 00 00 00 00       	mov    $0x0,%ebx
  801ecd:	8b b5 88 fd ff ff    	mov    -0x278(%ebp),%esi
  801ed3:	eb 2b                	jmp    801f00 <spawn+0x454>
		if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) &&
				(uvpt[PGNUM(addr)] & PTE_U) && (uvpt[PGNUM(addr)] & PTE_SHARE)) {
            sys_page_map(0, (void*)addr, child, (void*)addr, (uvpt[PGNUM(addr)] & PTE_SYSCALL));
  801ed5:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801edc:	83 ec 0c             	sub    $0xc,%esp
  801edf:	25 07 0e 00 00       	and    $0xe07,%eax
  801ee4:	50                   	push   %eax
  801ee5:	53                   	push   %ebx
  801ee6:	56                   	push   %esi
  801ee7:	53                   	push   %ebx
  801ee8:	6a 00                	push   $0x0
  801eea:	e8 68 ee ff ff       	call   800d57 <sys_page_map>
  801eef:	83 c4 20             	add    $0x20,%esp
	for (addr = 0; addr < UTOP; addr += PGSIZE) {
  801ef2:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  801ef8:	81 fb 00 00 c0 ee    	cmp    $0xeec00000,%ebx
  801efe:	74 3b                	je     801f3b <spawn+0x48f>
		if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) &&
  801f00:	89 d8                	mov    %ebx,%eax
  801f02:	c1 e8 16             	shr    $0x16,%eax
  801f05:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801f0c:	a8 01                	test   $0x1,%al
  801f0e:	74 e2                	je     801ef2 <spawn+0x446>
  801f10:	89 d8                	mov    %ebx,%eax
  801f12:	c1 e8 0c             	shr    $0xc,%eax
  801f15:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801f1c:	f6 c2 01             	test   $0x1,%dl
  801f1f:	74 d1                	je     801ef2 <spawn+0x446>
				(uvpt[PGNUM(addr)] & PTE_U) && (uvpt[PGNUM(addr)] & PTE_SHARE)) {
  801f21:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
		if ((uvpd[PDX(addr)] & PTE_P) && (uvpt[PGNUM(addr)] & PTE_P) &&
  801f28:	f6 c2 04             	test   $0x4,%dl
  801f2b:	74 c5                	je     801ef2 <spawn+0x446>
				(uvpt[PGNUM(addr)] & PTE_U) && (uvpt[PGNUM(addr)] & PTE_SHARE)) {
  801f2d:	8b 14 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%edx
  801f34:	f6 c6 04             	test   $0x4,%dh
  801f37:	74 b9                	je     801ef2 <spawn+0x446>
  801f39:	eb 9a                	jmp    801ed5 <spawn+0x429>
	child_tf.tf_eflags |= FL_IOPL_3;   // devious: see user/faultio.c
  801f3b:	81 8d dc fd ff ff 00 	orl    $0x3000,-0x224(%ebp)
  801f42:	30 00 00 
	if ((r = sys_env_set_trapframe(child, &child_tf)) < 0)
  801f45:	83 ec 08             	sub    $0x8,%esp
  801f48:	8d 85 a4 fd ff ff    	lea    -0x25c(%ebp),%eax
  801f4e:	50                   	push   %eax
  801f4f:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  801f55:	e8 cf ee ff ff       	call   800e29 <sys_env_set_trapframe>
  801f5a:	83 c4 10             	add    $0x10,%esp
  801f5d:	85 c0                	test   %eax,%eax
  801f5f:	78 25                	js     801f86 <spawn+0x4da>
	if ((r = sys_env_set_status(child, ENV_RUNNABLE)) < 0)
  801f61:	83 ec 08             	sub    $0x8,%esp
  801f64:	6a 02                	push   $0x2
  801f66:	ff b5 74 fd ff ff    	pushl  -0x28c(%ebp)
  801f6c:	e8 72 ee ff ff       	call   800de3 <sys_env_set_status>
  801f71:	83 c4 10             	add    $0x10,%esp
  801f74:	85 c0                	test   %eax,%eax
  801f76:	78 23                	js     801f9b <spawn+0x4ef>
	return child;
  801f78:	8b 85 74 fd ff ff    	mov    -0x28c(%ebp),%eax
  801f7e:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  801f84:	eb 36                	jmp    801fbc <spawn+0x510>
		panic("sys_env_set_trapframe: %e", r);
  801f86:	50                   	push   %eax
  801f87:	68 be 30 80 00       	push   $0x8030be
  801f8c:	68 86 00 00 00       	push   $0x86
  801f91:	68 95 30 80 00       	push   $0x803095
  801f96:	e8 73 e2 ff ff       	call   80020e <_panic>
		panic("sys_env_set_status: %e", r);
  801f9b:	50                   	push   %eax
  801f9c:	68 d8 30 80 00       	push   $0x8030d8
  801fa1:	68 89 00 00 00       	push   $0x89
  801fa6:	68 95 30 80 00       	push   $0x803095
  801fab:	e8 5e e2 ff ff       	call   80020e <_panic>
		return r;
  801fb0:	8b 85 74 fd ff ff    	mov    -0x28c(%ebp),%eax
  801fb6:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
}
  801fbc:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  801fc2:	8d 65 f4             	lea    -0xc(%ebp),%esp
  801fc5:	5b                   	pop    %ebx
  801fc6:	5e                   	pop    %esi
  801fc7:	5f                   	pop    %edi
  801fc8:	5d                   	pop    %ebp
  801fc9:	c3                   	ret    
  801fca:	89 c7                	mov    %eax,%edi
  801fcc:	e9 1b fe ff ff       	jmp    801dec <spawn+0x340>
  801fd1:	89 c7                	mov    %eax,%edi
  801fd3:	e9 14 fe ff ff       	jmp    801dec <spawn+0x340>
  801fd8:	89 c7                	mov    %eax,%edi
  801fda:	e9 0d fe ff ff       	jmp    801dec <spawn+0x340>
		return -E_NO_MEM;
  801fdf:	b8 fc ff ff ff       	mov    $0xfffffffc,%eax
	for (addr = 0; addr < UTOP; addr += PGSIZE) {
  801fe4:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  801fea:	eb d0                	jmp    801fbc <spawn+0x510>
	sys_page_unmap(0, UTEMP);
  801fec:	83 ec 08             	sub    $0x8,%esp
  801fef:	68 00 00 40 00       	push   $0x400000
  801ff4:	6a 00                	push   $0x0
  801ff6:	e8 a2 ed ff ff       	call   800d9d <sys_page_unmap>
  801ffb:	83 c4 10             	add    $0x10,%esp
  801ffe:	89 9d 94 fd ff ff    	mov    %ebx,-0x26c(%ebp)
  802004:	eb b6                	jmp    801fbc <spawn+0x510>

00802006 <spawnl>:
{
  802006:	f3 0f 1e fb          	endbr32 
  80200a:	55                   	push   %ebp
  80200b:	89 e5                	mov    %esp,%ebp
  80200d:	57                   	push   %edi
  80200e:	56                   	push   %esi
  80200f:	53                   	push   %ebx
  802010:	83 ec 0c             	sub    $0xc,%esp
	va_start(vl, arg0);
  802013:	8d 55 10             	lea    0x10(%ebp),%edx
	int argc=0;
  802016:	b8 00 00 00 00       	mov    $0x0,%eax
	while(va_arg(vl, void *) != NULL)
  80201b:	8d 4a 04             	lea    0x4(%edx),%ecx
  80201e:	83 3a 00             	cmpl   $0x0,(%edx)
  802021:	74 07                	je     80202a <spawnl+0x24>
		argc++;
  802023:	83 c0 01             	add    $0x1,%eax
	while(va_arg(vl, void *) != NULL)
  802026:	89 ca                	mov    %ecx,%edx
  802028:	eb f1                	jmp    80201b <spawnl+0x15>
	const char *argv[argc+2];
  80202a:	8d 14 85 17 00 00 00 	lea    0x17(,%eax,4),%edx
  802031:	89 d1                	mov    %edx,%ecx
  802033:	83 e1 f0             	and    $0xfffffff0,%ecx
  802036:	81 e2 00 f0 ff ff    	and    $0xfffff000,%edx
  80203c:	89 e6                	mov    %esp,%esi
  80203e:	29 d6                	sub    %edx,%esi
  802040:	89 f2                	mov    %esi,%edx
  802042:	39 d4                	cmp    %edx,%esp
  802044:	74 10                	je     802056 <spawnl+0x50>
  802046:	81 ec 00 10 00 00    	sub    $0x1000,%esp
  80204c:	83 8c 24 fc 0f 00 00 	orl    $0x0,0xffc(%esp)
  802053:	00 
  802054:	eb ec                	jmp    802042 <spawnl+0x3c>
  802056:	89 ca                	mov    %ecx,%edx
  802058:	81 e2 ff 0f 00 00    	and    $0xfff,%edx
  80205e:	29 d4                	sub    %edx,%esp
  802060:	85 d2                	test   %edx,%edx
  802062:	74 05                	je     802069 <spawnl+0x63>
  802064:	83 4c 14 fc 00       	orl    $0x0,-0x4(%esp,%edx,1)
  802069:	8d 74 24 03          	lea    0x3(%esp),%esi
  80206d:	89 f2                	mov    %esi,%edx
  80206f:	c1 ea 02             	shr    $0x2,%edx
  802072:	83 e6 fc             	and    $0xfffffffc,%esi
  802075:	89 f3                	mov    %esi,%ebx
	argv[0] = arg0;
  802077:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80207a:	89 0c 95 00 00 00 00 	mov    %ecx,0x0(,%edx,4)
	argv[argc+1] = NULL;
  802081:	c7 44 86 04 00 00 00 	movl   $0x0,0x4(%esi,%eax,4)
  802088:	00 
	va_start(vl, arg0);
  802089:	8d 4d 10             	lea    0x10(%ebp),%ecx
  80208c:	89 c2                	mov    %eax,%edx
	for(i=0;i<argc;i++)
  80208e:	b8 00 00 00 00       	mov    $0x0,%eax
  802093:	eb 0b                	jmp    8020a0 <spawnl+0x9a>
		argv[i+1] = va_arg(vl, const char *);
  802095:	83 c0 01             	add    $0x1,%eax
  802098:	8b 39                	mov    (%ecx),%edi
  80209a:	89 3c 83             	mov    %edi,(%ebx,%eax,4)
  80209d:	8d 49 04             	lea    0x4(%ecx),%ecx
	for(i=0;i<argc;i++)
  8020a0:	39 d0                	cmp    %edx,%eax
  8020a2:	75 f1                	jne    802095 <spawnl+0x8f>
	return spawn(prog, argv);
  8020a4:	83 ec 08             	sub    $0x8,%esp
  8020a7:	56                   	push   %esi
  8020a8:	ff 75 08             	pushl  0x8(%ebp)
  8020ab:	e8 fc f9 ff ff       	call   801aac <spawn>
}
  8020b0:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8020b3:	5b                   	pop    %ebx
  8020b4:	5e                   	pop    %esi
  8020b5:	5f                   	pop    %edi
  8020b6:	5d                   	pop    %ebp
  8020b7:	c3                   	ret    

008020b8 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  8020b8:	f3 0f 1e fb          	endbr32 
  8020bc:	55                   	push   %ebp
  8020bd:	89 e5                	mov    %esp,%ebp
  8020bf:	56                   	push   %esi
  8020c0:	53                   	push   %ebx
  8020c1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  8020c4:	83 ec 0c             	sub    $0xc,%esp
  8020c7:	ff 75 08             	pushl  0x8(%ebp)
  8020ca:	e8 a7 f1 ff ff       	call   801276 <fd2data>
  8020cf:	89 c6                	mov    %eax,%esi
	strcpy(stat->st_name, "<pipe>");
  8020d1:	83 c4 08             	add    $0x8,%esp
  8020d4:	68 16 31 80 00       	push   $0x803116
  8020d9:	53                   	push   %ebx
  8020da:	e8 ef e7 ff ff       	call   8008ce <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  8020df:	8b 46 04             	mov    0x4(%esi),%eax
  8020e2:	2b 06                	sub    (%esi),%eax
  8020e4:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	stat->st_isdir = 0;
  8020ea:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8020f1:	00 00 00 
	stat->st_dev = &devpipe;
  8020f4:	c7 83 88 00 00 00 28 	movl   $0x804028,0x88(%ebx)
  8020fb:	40 80 00 
	return 0;
}
  8020fe:	b8 00 00 00 00       	mov    $0x0,%eax
  802103:	8d 65 f8             	lea    -0x8(%ebp),%esp
  802106:	5b                   	pop    %ebx
  802107:	5e                   	pop    %esi
  802108:	5d                   	pop    %ebp
  802109:	c3                   	ret    

0080210a <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  80210a:	f3 0f 1e fb          	endbr32 
  80210e:	55                   	push   %ebp
  80210f:	89 e5                	mov    %esp,%ebp
  802111:	53                   	push   %ebx
  802112:	83 ec 0c             	sub    $0xc,%esp
  802115:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802118:	53                   	push   %ebx
  802119:	6a 00                	push   $0x0
  80211b:	e8 7d ec ff ff       	call   800d9d <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802120:	89 1c 24             	mov    %ebx,(%esp)
  802123:	e8 4e f1 ff ff       	call   801276 <fd2data>
  802128:	83 c4 08             	add    $0x8,%esp
  80212b:	50                   	push   %eax
  80212c:	6a 00                	push   $0x0
  80212e:	e8 6a ec ff ff       	call   800d9d <sys_page_unmap>
}
  802133:	8b 5d fc             	mov    -0x4(%ebp),%ebx
  802136:	c9                   	leave  
  802137:	c3                   	ret    

00802138 <_pipeisclosed>:
{
  802138:	55                   	push   %ebp
  802139:	89 e5                	mov    %esp,%ebp
  80213b:	57                   	push   %edi
  80213c:	56                   	push   %esi
  80213d:	53                   	push   %ebx
  80213e:	83 ec 1c             	sub    $0x1c,%esp
  802141:	89 c7                	mov    %eax,%edi
  802143:	89 d6                	mov    %edx,%esi
		n = thisenv->env_runs;
  802145:	a1 04 50 80 00       	mov    0x805004,%eax
  80214a:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  80214d:	83 ec 0c             	sub    $0xc,%esp
  802150:	57                   	push   %edi
  802151:	e8 67 06 00 00       	call   8027bd <pageref>
  802156:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  802159:	89 34 24             	mov    %esi,(%esp)
  80215c:	e8 5c 06 00 00       	call   8027bd <pageref>
		nn = thisenv->env_runs;
  802161:	8b 15 04 50 80 00    	mov    0x805004,%edx
  802167:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80216a:	83 c4 10             	add    $0x10,%esp
  80216d:	39 cb                	cmp    %ecx,%ebx
  80216f:	74 1b                	je     80218c <_pipeisclosed+0x54>
		if (n != nn && ret == 1)
  802171:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  802174:	75 cf                	jne    802145 <_pipeisclosed+0xd>
			cprintf("pipe race avoided\n", n, thisenv->env_runs, ret);
  802176:	8b 42 58             	mov    0x58(%edx),%eax
  802179:	6a 01                	push   $0x1
  80217b:	50                   	push   %eax
  80217c:	53                   	push   %ebx
  80217d:	68 1d 31 80 00       	push   $0x80311d
  802182:	e8 6e e1 ff ff       	call   8002f5 <cprintf>
  802187:	83 c4 10             	add    $0x10,%esp
  80218a:	eb b9                	jmp    802145 <_pipeisclosed+0xd>
		ret = pageref(fd) == pageref(p);
  80218c:	39 45 e4             	cmp    %eax,-0x1c(%ebp)
  80218f:	0f 94 c0             	sete   %al
  802192:	0f b6 c0             	movzbl %al,%eax
}
  802195:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802198:	5b                   	pop    %ebx
  802199:	5e                   	pop    %esi
  80219a:	5f                   	pop    %edi
  80219b:	5d                   	pop    %ebp
  80219c:	c3                   	ret    

0080219d <devpipe_write>:
{
  80219d:	f3 0f 1e fb          	endbr32 
  8021a1:	55                   	push   %ebp
  8021a2:	89 e5                	mov    %esp,%ebp
  8021a4:	57                   	push   %edi
  8021a5:	56                   	push   %esi
  8021a6:	53                   	push   %ebx
  8021a7:	83 ec 28             	sub    $0x28,%esp
  8021aa:	8b 75 08             	mov    0x8(%ebp),%esi
	p = (struct Pipe*) fd2data(fd);
  8021ad:	56                   	push   %esi
  8021ae:	e8 c3 f0 ff ff       	call   801276 <fd2data>
  8021b3:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  8021b5:	83 c4 10             	add    $0x10,%esp
  8021b8:	bf 00 00 00 00       	mov    $0x0,%edi
  8021bd:	3b 7d 10             	cmp    0x10(%ebp),%edi
  8021c0:	74 4f                	je     802211 <devpipe_write+0x74>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8021c2:	8b 43 04             	mov    0x4(%ebx),%eax
  8021c5:	8b 0b                	mov    (%ebx),%ecx
  8021c7:	8d 51 20             	lea    0x20(%ecx),%edx
  8021ca:	39 d0                	cmp    %edx,%eax
  8021cc:	72 14                	jb     8021e2 <devpipe_write+0x45>
			if (_pipeisclosed(fd, p))
  8021ce:	89 da                	mov    %ebx,%edx
  8021d0:	89 f0                	mov    %esi,%eax
  8021d2:	e8 61 ff ff ff       	call   802138 <_pipeisclosed>
  8021d7:	85 c0                	test   %eax,%eax
  8021d9:	75 3b                	jne    802216 <devpipe_write+0x79>
			sys_yield();
  8021db:	e8 0d eb ff ff       	call   800ced <sys_yield>
  8021e0:	eb e0                	jmp    8021c2 <devpipe_write+0x25>
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  8021e2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8021e5:	0f b6 0c 39          	movzbl (%ecx,%edi,1),%ecx
  8021e9:	88 4d e7             	mov    %cl,-0x19(%ebp)
  8021ec:	89 c2                	mov    %eax,%edx
  8021ee:	c1 fa 1f             	sar    $0x1f,%edx
  8021f1:	89 d1                	mov    %edx,%ecx
  8021f3:	c1 e9 1b             	shr    $0x1b,%ecx
  8021f6:	8d 14 08             	lea    (%eax,%ecx,1),%edx
  8021f9:	83 e2 1f             	and    $0x1f,%edx
  8021fc:	29 ca                	sub    %ecx,%edx
  8021fe:	0f b6 4d e7          	movzbl -0x19(%ebp),%ecx
  802202:	88 4c 13 08          	mov    %cl,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802206:	83 c0 01             	add    $0x1,%eax
  802209:	89 43 04             	mov    %eax,0x4(%ebx)
	for (i = 0; i < n; i++) {
  80220c:	83 c7 01             	add    $0x1,%edi
  80220f:	eb ac                	jmp    8021bd <devpipe_write+0x20>
	return i;
  802211:	8b 45 10             	mov    0x10(%ebp),%eax
  802214:	eb 05                	jmp    80221b <devpipe_write+0x7e>
				return 0;
  802216:	b8 00 00 00 00       	mov    $0x0,%eax
}
  80221b:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80221e:	5b                   	pop    %ebx
  80221f:	5e                   	pop    %esi
  802220:	5f                   	pop    %edi
  802221:	5d                   	pop    %ebp
  802222:	c3                   	ret    

00802223 <devpipe_read>:
{
  802223:	f3 0f 1e fb          	endbr32 
  802227:	55                   	push   %ebp
  802228:	89 e5                	mov    %esp,%ebp
  80222a:	57                   	push   %edi
  80222b:	56                   	push   %esi
  80222c:	53                   	push   %ebx
  80222d:	83 ec 18             	sub    $0x18,%esp
  802230:	8b 7d 08             	mov    0x8(%ebp),%edi
	p = (struct Pipe*)fd2data(fd);
  802233:	57                   	push   %edi
  802234:	e8 3d f0 ff ff       	call   801276 <fd2data>
  802239:	89 c3                	mov    %eax,%ebx
	for (i = 0; i < n; i++) {
  80223b:	83 c4 10             	add    $0x10,%esp
  80223e:	be 00 00 00 00       	mov    $0x0,%esi
  802243:	3b 75 10             	cmp    0x10(%ebp),%esi
  802246:	75 14                	jne    80225c <devpipe_read+0x39>
	return i;
  802248:	8b 45 10             	mov    0x10(%ebp),%eax
  80224b:	eb 02                	jmp    80224f <devpipe_read+0x2c>
				return i;
  80224d:	89 f0                	mov    %esi,%eax
}
  80224f:	8d 65 f4             	lea    -0xc(%ebp),%esp
  802252:	5b                   	pop    %ebx
  802253:	5e                   	pop    %esi
  802254:	5f                   	pop    %edi
  802255:	5d                   	pop    %ebp
  802256:	c3                   	ret    
			sys_yield();
  802257:	e8 91 ea ff ff       	call   800ced <sys_yield>
		while (p->p_rpos == p->p_wpos) {
  80225c:	8b 03                	mov    (%ebx),%eax
  80225e:	3b 43 04             	cmp    0x4(%ebx),%eax
  802261:	75 18                	jne    80227b <devpipe_read+0x58>
			if (i > 0)
  802263:	85 f6                	test   %esi,%esi
  802265:	75 e6                	jne    80224d <devpipe_read+0x2a>
			if (_pipeisclosed(fd, p))
  802267:	89 da                	mov    %ebx,%edx
  802269:	89 f8                	mov    %edi,%eax
  80226b:	e8 c8 fe ff ff       	call   802138 <_pipeisclosed>
  802270:	85 c0                	test   %eax,%eax
  802272:	74 e3                	je     802257 <devpipe_read+0x34>
				return 0;
  802274:	b8 00 00 00 00       	mov    $0x0,%eax
  802279:	eb d4                	jmp    80224f <devpipe_read+0x2c>
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80227b:	99                   	cltd   
  80227c:	c1 ea 1b             	shr    $0x1b,%edx
  80227f:	01 d0                	add    %edx,%eax
  802281:	83 e0 1f             	and    $0x1f,%eax
  802284:	29 d0                	sub    %edx,%eax
  802286:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  80228b:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80228e:	88 04 31             	mov    %al,(%ecx,%esi,1)
		p->p_rpos++;
  802291:	83 03 01             	addl   $0x1,(%ebx)
	for (i = 0; i < n; i++) {
  802294:	83 c6 01             	add    $0x1,%esi
  802297:	eb aa                	jmp    802243 <devpipe_read+0x20>

00802299 <pipe>:
{
  802299:	f3 0f 1e fb          	endbr32 
  80229d:	55                   	push   %ebp
  80229e:	89 e5                	mov    %esp,%ebp
  8022a0:	56                   	push   %esi
  8022a1:	53                   	push   %ebx
  8022a2:	83 ec 1c             	sub    $0x1c,%esp
	if ((r = fd_alloc(&fd0)) < 0
  8022a5:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8022a8:	50                   	push   %eax
  8022a9:	e8 e3 ef ff ff       	call   801291 <fd_alloc>
  8022ae:	89 c3                	mov    %eax,%ebx
  8022b0:	83 c4 10             	add    $0x10,%esp
  8022b3:	85 c0                	test   %eax,%eax
  8022b5:	0f 88 23 01 00 00    	js     8023de <pipe+0x145>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8022bb:	83 ec 04             	sub    $0x4,%esp
  8022be:	68 07 04 00 00       	push   $0x407
  8022c3:	ff 75 f4             	pushl  -0xc(%ebp)
  8022c6:	6a 00                	push   $0x0
  8022c8:	e8 43 ea ff ff       	call   800d10 <sys_page_alloc>
  8022cd:	89 c3                	mov    %eax,%ebx
  8022cf:	83 c4 10             	add    $0x10,%esp
  8022d2:	85 c0                	test   %eax,%eax
  8022d4:	0f 88 04 01 00 00    	js     8023de <pipe+0x145>
	if ((r = fd_alloc(&fd1)) < 0
  8022da:	83 ec 0c             	sub    $0xc,%esp
  8022dd:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8022e0:	50                   	push   %eax
  8022e1:	e8 ab ef ff ff       	call   801291 <fd_alloc>
  8022e6:	89 c3                	mov    %eax,%ebx
  8022e8:	83 c4 10             	add    $0x10,%esp
  8022eb:	85 c0                	test   %eax,%eax
  8022ed:	0f 88 db 00 00 00    	js     8023ce <pipe+0x135>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8022f3:	83 ec 04             	sub    $0x4,%esp
  8022f6:	68 07 04 00 00       	push   $0x407
  8022fb:	ff 75 f0             	pushl  -0x10(%ebp)
  8022fe:	6a 00                	push   $0x0
  802300:	e8 0b ea ff ff       	call   800d10 <sys_page_alloc>
  802305:	89 c3                	mov    %eax,%ebx
  802307:	83 c4 10             	add    $0x10,%esp
  80230a:	85 c0                	test   %eax,%eax
  80230c:	0f 88 bc 00 00 00    	js     8023ce <pipe+0x135>
	va = fd2data(fd0);
  802312:	83 ec 0c             	sub    $0xc,%esp
  802315:	ff 75 f4             	pushl  -0xc(%ebp)
  802318:	e8 59 ef ff ff       	call   801276 <fd2data>
  80231d:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80231f:	83 c4 0c             	add    $0xc,%esp
  802322:	68 07 04 00 00       	push   $0x407
  802327:	50                   	push   %eax
  802328:	6a 00                	push   $0x0
  80232a:	e8 e1 e9 ff ff       	call   800d10 <sys_page_alloc>
  80232f:	89 c3                	mov    %eax,%ebx
  802331:	83 c4 10             	add    $0x10,%esp
  802334:	85 c0                	test   %eax,%eax
  802336:	0f 88 82 00 00 00    	js     8023be <pipe+0x125>
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80233c:	83 ec 0c             	sub    $0xc,%esp
  80233f:	ff 75 f0             	pushl  -0x10(%ebp)
  802342:	e8 2f ef ff ff       	call   801276 <fd2data>
  802347:	c7 04 24 07 04 00 00 	movl   $0x407,(%esp)
  80234e:	50                   	push   %eax
  80234f:	6a 00                	push   $0x0
  802351:	56                   	push   %esi
  802352:	6a 00                	push   $0x0
  802354:	e8 fe e9 ff ff       	call   800d57 <sys_page_map>
  802359:	89 c3                	mov    %eax,%ebx
  80235b:	83 c4 20             	add    $0x20,%esp
  80235e:	85 c0                	test   %eax,%eax
  802360:	78 4e                	js     8023b0 <pipe+0x117>
	fd0->fd_dev_id = devpipe.dev_id;
  802362:	a1 28 40 80 00       	mov    0x804028,%eax
  802367:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80236a:	89 02                	mov    %eax,(%edx)
	fd0->fd_omode = O_RDONLY;
  80236c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80236f:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)
	fd1->fd_dev_id = devpipe.dev_id;
  802376:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802379:	89 02                	mov    %eax,(%edx)
	fd1->fd_omode = O_WRONLY;
  80237b:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80237e:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)
	pfd[0] = fd2num(fd0);
  802385:	83 ec 0c             	sub    $0xc,%esp
  802388:	ff 75 f4             	pushl  -0xc(%ebp)
  80238b:	e8 d2 ee ff ff       	call   801262 <fd2num>
  802390:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802393:	89 01                	mov    %eax,(%ecx)
	pfd[1] = fd2num(fd1);
  802395:	83 c4 04             	add    $0x4,%esp
  802398:	ff 75 f0             	pushl  -0x10(%ebp)
  80239b:	e8 c2 ee ff ff       	call   801262 <fd2num>
  8023a0:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8023a3:	89 41 04             	mov    %eax,0x4(%ecx)
	return 0;
  8023a6:	83 c4 10             	add    $0x10,%esp
  8023a9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8023ae:	eb 2e                	jmp    8023de <pipe+0x145>
	sys_page_unmap(0, va);
  8023b0:	83 ec 08             	sub    $0x8,%esp
  8023b3:	56                   	push   %esi
  8023b4:	6a 00                	push   $0x0
  8023b6:	e8 e2 e9 ff ff       	call   800d9d <sys_page_unmap>
  8023bb:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd1);
  8023be:	83 ec 08             	sub    $0x8,%esp
  8023c1:	ff 75 f0             	pushl  -0x10(%ebp)
  8023c4:	6a 00                	push   $0x0
  8023c6:	e8 d2 e9 ff ff       	call   800d9d <sys_page_unmap>
  8023cb:	83 c4 10             	add    $0x10,%esp
	sys_page_unmap(0, fd0);
  8023ce:	83 ec 08             	sub    $0x8,%esp
  8023d1:	ff 75 f4             	pushl  -0xc(%ebp)
  8023d4:	6a 00                	push   $0x0
  8023d6:	e8 c2 e9 ff ff       	call   800d9d <sys_page_unmap>
  8023db:	83 c4 10             	add    $0x10,%esp
}
  8023de:	89 d8                	mov    %ebx,%eax
  8023e0:	8d 65 f8             	lea    -0x8(%ebp),%esp
  8023e3:	5b                   	pop    %ebx
  8023e4:	5e                   	pop    %esi
  8023e5:	5d                   	pop    %ebp
  8023e6:	c3                   	ret    

008023e7 <pipeisclosed>:
{
  8023e7:	f3 0f 1e fb          	endbr32 
  8023eb:	55                   	push   %ebp
  8023ec:	89 e5                	mov    %esp,%ebp
  8023ee:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8023f1:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8023f4:	50                   	push   %eax
  8023f5:	ff 75 08             	pushl  0x8(%ebp)
  8023f8:	e8 ea ee ff ff       	call   8012e7 <fd_lookup>
  8023fd:	83 c4 10             	add    $0x10,%esp
  802400:	85 c0                	test   %eax,%eax
  802402:	78 18                	js     80241c <pipeisclosed+0x35>
	p = (struct Pipe*) fd2data(fd);
  802404:	83 ec 0c             	sub    $0xc,%esp
  802407:	ff 75 f4             	pushl  -0xc(%ebp)
  80240a:	e8 67 ee ff ff       	call   801276 <fd2data>
  80240f:	89 c2                	mov    %eax,%edx
	return _pipeisclosed(fd, p);
  802411:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802414:	e8 1f fd ff ff       	call   802138 <_pipeisclosed>
  802419:	83 c4 10             	add    $0x10,%esp
}
  80241c:	c9                   	leave  
  80241d:	c3                   	ret    

0080241e <wait>:
#include <inc/lib.h>

// Waits until 'envid' exits.
void
wait(envid_t envid)
{
  80241e:	f3 0f 1e fb          	endbr32 
  802422:	55                   	push   %ebp
  802423:	89 e5                	mov    %esp,%ebp
  802425:	56                   	push   %esi
  802426:	53                   	push   %ebx
  802427:	8b 75 08             	mov    0x8(%ebp),%esi
	const volatile struct Env *e;

	assert(envid != 0);
  80242a:	85 f6                	test   %esi,%esi
  80242c:	74 13                	je     802441 <wait+0x23>
	e = &envs[ENVX(envid)];
  80242e:	89 f3                	mov    %esi,%ebx
  802430:	81 e3 ff 03 00 00    	and    $0x3ff,%ebx
	while (e->env_id == envid && e->env_status != ENV_FREE)
  802436:	6b db 7c             	imul   $0x7c,%ebx,%ebx
  802439:	81 c3 00 00 c0 ee    	add    $0xeec00000,%ebx
  80243f:	eb 1b                	jmp    80245c <wait+0x3e>
	assert(envid != 0);
  802441:	68 35 31 80 00       	push   $0x803135
  802446:	68 4f 30 80 00       	push   $0x80304f
  80244b:	6a 09                	push   $0x9
  80244d:	68 40 31 80 00       	push   $0x803140
  802452:	e8 b7 dd ff ff       	call   80020e <_panic>
		sys_yield();
  802457:	e8 91 e8 ff ff       	call   800ced <sys_yield>
	while (e->env_id == envid && e->env_status != ENV_FREE)
  80245c:	8b 43 48             	mov    0x48(%ebx),%eax
  80245f:	39 f0                	cmp    %esi,%eax
  802461:	75 07                	jne    80246a <wait+0x4c>
  802463:	8b 43 54             	mov    0x54(%ebx),%eax
  802466:	85 c0                	test   %eax,%eax
  802468:	75 ed                	jne    802457 <wait+0x39>
}
  80246a:	8d 65 f8             	lea    -0x8(%ebp),%esp
  80246d:	5b                   	pop    %ebx
  80246e:	5e                   	pop    %esi
  80246f:	5d                   	pop    %ebp
  802470:	c3                   	ret    

00802471 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802471:	f3 0f 1e fb          	endbr32 
	USED(fd);

	return 0;
}
  802475:	b8 00 00 00 00       	mov    $0x0,%eax
  80247a:	c3                   	ret    

0080247b <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80247b:	f3 0f 1e fb          	endbr32 
  80247f:	55                   	push   %ebp
  802480:	89 e5                	mov    %esp,%ebp
  802482:	83 ec 10             	sub    $0x10,%esp
	strcpy(stat->st_name, "<cons>");
  802485:	68 4b 31 80 00       	push   $0x80314b
  80248a:	ff 75 0c             	pushl  0xc(%ebp)
  80248d:	e8 3c e4 ff ff       	call   8008ce <strcpy>
	return 0;
}
  802492:	b8 00 00 00 00       	mov    $0x0,%eax
  802497:	c9                   	leave  
  802498:	c3                   	ret    

00802499 <devcons_write>:
{
  802499:	f3 0f 1e fb          	endbr32 
  80249d:	55                   	push   %ebp
  80249e:	89 e5                	mov    %esp,%ebp
  8024a0:	57                   	push   %edi
  8024a1:	56                   	push   %esi
  8024a2:	53                   	push   %ebx
  8024a3:	81 ec 8c 00 00 00    	sub    $0x8c,%esp
	for (tot = 0; tot < n; tot += m) {
  8024a9:	be 00 00 00 00       	mov    $0x0,%esi
		memmove(buf, (char*)vbuf + tot, m);
  8024ae:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	for (tot = 0; tot < n; tot += m) {
  8024b4:	3b 75 10             	cmp    0x10(%ebp),%esi
  8024b7:	73 31                	jae    8024ea <devcons_write+0x51>
		m = n - tot;
  8024b9:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8024bc:	29 f3                	sub    %esi,%ebx
  8024be:	83 fb 7f             	cmp    $0x7f,%ebx
  8024c1:	b8 7f 00 00 00       	mov    $0x7f,%eax
  8024c6:	0f 47 d8             	cmova  %eax,%ebx
		memmove(buf, (char*)vbuf + tot, m);
  8024c9:	83 ec 04             	sub    $0x4,%esp
  8024cc:	53                   	push   %ebx
  8024cd:	89 f0                	mov    %esi,%eax
  8024cf:	03 45 0c             	add    0xc(%ebp),%eax
  8024d2:	50                   	push   %eax
  8024d3:	57                   	push   %edi
  8024d4:	e8 ab e5 ff ff       	call   800a84 <memmove>
		sys_cputs(buf, m);
  8024d9:	83 c4 08             	add    $0x8,%esp
  8024dc:	53                   	push   %ebx
  8024dd:	57                   	push   %edi
  8024de:	e8 5d e7 ff ff       	call   800c40 <sys_cputs>
	for (tot = 0; tot < n; tot += m) {
  8024e3:	01 de                	add    %ebx,%esi
  8024e5:	83 c4 10             	add    $0x10,%esp
  8024e8:	eb ca                	jmp    8024b4 <devcons_write+0x1b>
}
  8024ea:	89 f0                	mov    %esi,%eax
  8024ec:	8d 65 f4             	lea    -0xc(%ebp),%esp
  8024ef:	5b                   	pop    %ebx
  8024f0:	5e                   	pop    %esi
  8024f1:	5f                   	pop    %edi
  8024f2:	5d                   	pop    %ebp
  8024f3:	c3                   	ret    

008024f4 <devcons_read>:
{
  8024f4:	f3 0f 1e fb          	endbr32 
  8024f8:	55                   	push   %ebp
  8024f9:	89 e5                	mov    %esp,%ebp
  8024fb:	83 ec 08             	sub    $0x8,%esp
  8024fe:	b8 00 00 00 00       	mov    $0x0,%eax
	if (n == 0)
  802503:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802507:	74 21                	je     80252a <devcons_read+0x36>
	while ((c = sys_cgetc()) == 0)
  802509:	e8 54 e7 ff ff       	call   800c62 <sys_cgetc>
  80250e:	85 c0                	test   %eax,%eax
  802510:	75 07                	jne    802519 <devcons_read+0x25>
		sys_yield();
  802512:	e8 d6 e7 ff ff       	call   800ced <sys_yield>
  802517:	eb f0                	jmp    802509 <devcons_read+0x15>
	if (c < 0)
  802519:	78 0f                	js     80252a <devcons_read+0x36>
	if (c == 0x04)	// ctl-d is eof
  80251b:	83 f8 04             	cmp    $0x4,%eax
  80251e:	74 0c                	je     80252c <devcons_read+0x38>
	*(char*)vbuf = c;
  802520:	8b 55 0c             	mov    0xc(%ebp),%edx
  802523:	88 02                	mov    %al,(%edx)
	return 1;
  802525:	b8 01 00 00 00       	mov    $0x1,%eax
}
  80252a:	c9                   	leave  
  80252b:	c3                   	ret    
		return 0;
  80252c:	b8 00 00 00 00       	mov    $0x0,%eax
  802531:	eb f7                	jmp    80252a <devcons_read+0x36>

00802533 <cputchar>:
{
  802533:	f3 0f 1e fb          	endbr32 
  802537:	55                   	push   %ebp
  802538:	89 e5                	mov    %esp,%ebp
  80253a:	83 ec 20             	sub    $0x20,%esp
	char c = ch;
  80253d:	8b 45 08             	mov    0x8(%ebp),%eax
  802540:	88 45 f7             	mov    %al,-0x9(%ebp)
	sys_cputs(&c, 1);
  802543:	6a 01                	push   $0x1
  802545:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802548:	50                   	push   %eax
  802549:	e8 f2 e6 ff ff       	call   800c40 <sys_cputs>
}
  80254e:	83 c4 10             	add    $0x10,%esp
  802551:	c9                   	leave  
  802552:	c3                   	ret    

00802553 <getchar>:
{
  802553:	f3 0f 1e fb          	endbr32 
  802557:	55                   	push   %ebp
  802558:	89 e5                	mov    %esp,%ebp
  80255a:	83 ec 1c             	sub    $0x1c,%esp
	r = read(0, &c, 1);
  80255d:	6a 01                	push   $0x1
  80255f:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802562:	50                   	push   %eax
  802563:	6a 00                	push   $0x0
  802565:	e8 00 f0 ff ff       	call   80156a <read>
	if (r < 0)
  80256a:	83 c4 10             	add    $0x10,%esp
  80256d:	85 c0                	test   %eax,%eax
  80256f:	78 06                	js     802577 <getchar+0x24>
	if (r < 1)
  802571:	74 06                	je     802579 <getchar+0x26>
	return c;
  802573:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802577:	c9                   	leave  
  802578:	c3                   	ret    
		return -E_EOF;
  802579:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  80257e:	eb f7                	jmp    802577 <getchar+0x24>

00802580 <iscons>:
{
  802580:	f3 0f 1e fb          	endbr32 
  802584:	55                   	push   %ebp
  802585:	89 e5                	mov    %esp,%ebp
  802587:	83 ec 20             	sub    $0x20,%esp
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80258a:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80258d:	50                   	push   %eax
  80258e:	ff 75 08             	pushl  0x8(%ebp)
  802591:	e8 51 ed ff ff       	call   8012e7 <fd_lookup>
  802596:	83 c4 10             	add    $0x10,%esp
  802599:	85 c0                	test   %eax,%eax
  80259b:	78 11                	js     8025ae <iscons+0x2e>
	return fd->fd_dev_id == devcons.dev_id;
  80259d:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8025a0:	8b 15 44 40 80 00    	mov    0x804044,%edx
  8025a6:	39 10                	cmp    %edx,(%eax)
  8025a8:	0f 94 c0             	sete   %al
  8025ab:	0f b6 c0             	movzbl %al,%eax
}
  8025ae:	c9                   	leave  
  8025af:	c3                   	ret    

008025b0 <opencons>:
{
  8025b0:	f3 0f 1e fb          	endbr32 
  8025b4:	55                   	push   %ebp
  8025b5:	89 e5                	mov    %esp,%ebp
  8025b7:	83 ec 24             	sub    $0x24,%esp
	if ((r = fd_alloc(&fd)) < 0)
  8025ba:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8025bd:	50                   	push   %eax
  8025be:	e8 ce ec ff ff       	call   801291 <fd_alloc>
  8025c3:	83 c4 10             	add    $0x10,%esp
  8025c6:	85 c0                	test   %eax,%eax
  8025c8:	78 3a                	js     802604 <opencons+0x54>
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  8025ca:	83 ec 04             	sub    $0x4,%esp
  8025cd:	68 07 04 00 00       	push   $0x407
  8025d2:	ff 75 f4             	pushl  -0xc(%ebp)
  8025d5:	6a 00                	push   $0x0
  8025d7:	e8 34 e7 ff ff       	call   800d10 <sys_page_alloc>
  8025dc:	83 c4 10             	add    $0x10,%esp
  8025df:	85 c0                	test   %eax,%eax
  8025e1:	78 21                	js     802604 <opencons+0x54>
	fd->fd_dev_id = devcons.dev_id;
  8025e3:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8025e6:	8b 15 44 40 80 00    	mov    0x804044,%edx
  8025ec:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  8025ee:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8025f1:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  8025f8:	83 ec 0c             	sub    $0xc,%esp
  8025fb:	50                   	push   %eax
  8025fc:	e8 61 ec ff ff       	call   801262 <fd2num>
  802601:	83 c4 10             	add    $0x10,%esp
}
  802604:	c9                   	leave  
  802605:	c3                   	ret    

00802606 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802606:	f3 0f 1e fb          	endbr32 
  80260a:	55                   	push   %ebp
  80260b:	89 e5                	mov    %esp,%ebp
  80260d:	83 ec 08             	sub    $0x8,%esp
	int r;

	if (_pgfault_handler == 0) {
  802610:	83 3d 00 70 80 00 00 	cmpl   $0x0,0x807000
  802617:	74 27                	je     802640 <set_pgfault_handler+0x3a>
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
			panic("set_pgfault_handler:sys_page_alloc failed");
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802619:	8b 45 08             	mov    0x8(%ebp),%eax
  80261c:	a3 00 70 80 00       	mov    %eax,0x807000
	if (sys_env_set_pgfault_upcall(thisenv->env_id,_pgfault_upcall)<0)	
  802621:	a1 04 50 80 00       	mov    0x805004,%eax
  802626:	8b 40 48             	mov    0x48(%eax),%eax
  802629:	83 ec 08             	sub    $0x8,%esp
  80262c:	68 80 26 80 00       	push   $0x802680
  802631:	50                   	push   %eax
  802632:	e8 38 e8 ff ff       	call   800e6f <sys_env_set_pgfault_upcall>
  802637:	83 c4 10             	add    $0x10,%esp
  80263a:	85 c0                	test   %eax,%eax
  80263c:	78 2e                	js     80266c <set_pgfault_handler+0x66>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
}
  80263e:	c9                   	leave  
  80263f:	c3                   	ret    
		if(sys_page_alloc(0,(void *)UXSTACKTOP-PGSIZE,PTE_W|PTE_U|PTE_P)<0)
  802640:	83 ec 04             	sub    $0x4,%esp
  802643:	6a 07                	push   $0x7
  802645:	68 00 f0 bf ee       	push   $0xeebff000
  80264a:	6a 00                	push   $0x0
  80264c:	e8 bf e6 ff ff       	call   800d10 <sys_page_alloc>
  802651:	83 c4 10             	add    $0x10,%esp
  802654:	85 c0                	test   %eax,%eax
  802656:	79 c1                	jns    802619 <set_pgfault_handler+0x13>
			panic("set_pgfault_handler:sys_page_alloc failed");
  802658:	83 ec 04             	sub    $0x4,%esp
  80265b:	68 58 31 80 00       	push   $0x803158
  802660:	6a 21                	push   $0x21
  802662:	68 ba 31 80 00       	push   $0x8031ba
  802667:	e8 a2 db ff ff       	call   80020e <_panic>
        panic("set_pgfault_handler:sys_env_set_pgfault_upcall failed");
  80266c:	83 ec 04             	sub    $0x4,%esp
  80266f:	68 84 31 80 00       	push   $0x803184
  802674:	6a 27                	push   $0x27
  802676:	68 ba 31 80 00       	push   $0x8031ba
  80267b:	e8 8e db ff ff       	call   80020e <_panic>

00802680 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  802680:	54                   	push   %esp
	movl _pgfault_handler, %eax
  802681:	a1 00 70 80 00       	mov    0x807000,%eax
	call *%eax
  802686:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802688:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.
	//首先把此时的eip指针下移48个字节因为UTrapFrame的大小是48个字节
	movl 48(%esp), %ebp
  80268b:	8b 6c 24 30          	mov    0x30(%esp),%ebp
    subl $4, %ebp		// UTrapFrame.utf_esp - 4 and store back 这里是由于之前预留了4个字节。
  80268f:	83 ed 04             	sub    $0x4,%ebp
    movl %ebp, 48(%esp)	// 返回上一次的esp位置。
  802692:	89 6c 24 30          	mov    %ebp,0x30(%esp)

	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
	movl 40(%esp), %eax 
  802696:	8b 44 24 28          	mov    0x28(%esp),%eax
    movl %eax, (%ebp)
  80269a:	89 45 00             	mov    %eax,0x0(%ebp)

	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
	addl $0x8, %esp         // Set %esp to the end of struct PushRegs
  80269d:	83 c4 08             	add    $0x8,%esp
	popal                   // Restore the trap-time registers.(struct PushRegs)
  8026a0:	61                   	popa   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
	addl $0x4, %esp         // now we are located at trap-time eip,so we have to increment %esp with 4.【跳过eip】
  8026a1:	83 c4 04             	add    $0x4,%esp
	popfl                   // Restore eflags register.	【pop eflags】
  8026a4:	9d                   	popf   
	popl %esp               // Just restore the adjusted trap-time stack pointer.
  8026a5:	5c                   	pop    %esp
							// 恢复esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
	ret                     // We are now on the trap-time stack,since we have saved trap-time eip above trap-time esp,ret instruction will pop this trap-time eip to register %eip which known as PC at this time.Thus,we can return to re-execute the instruction that faulted.
  8026a6:	c3                   	ret    

008026a7 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  8026a7:	f3 0f 1e fb          	endbr32 
  8026ab:	55                   	push   %ebp
  8026ac:	89 e5                	mov    %esp,%ebp
  8026ae:	56                   	push   %esi
  8026af:	53                   	push   %ebx
  8026b0:	8b 75 08             	mov    0x8(%ebp),%esi
  8026b3:	8b 45 0c             	mov    0xc(%ebp),%eax
  8026b6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	int error;
	if(!pg)pg = (void *)UTOP; // 如果设置为UTOP，这个值其实可以比UTOP大，设置为这个值认为pg无效了，不会进行页面传递【共享页面的设置】，而是只进行值value的传递。
  8026b9:	85 c0                	test   %eax,%eax
  8026bb:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  8026c0:	0f 44 c2             	cmove  %edx,%eax
	if((error = sys_ipc_recv(pg)) < 0){
  8026c3:	83 ec 0c             	sub    $0xc,%esp
  8026c6:	50                   	push   %eax
  8026c7:	e8 10 e8 ff ff       	call   800edc <sys_ipc_recv>
  8026cc:	83 c4 10             	add    $0x10,%esp
  8026cf:	85 c0                	test   %eax,%eax
  8026d1:	78 3f                	js     802712 <ipc_recv+0x6b>
		if(from_env_store)*from_env_store = 0;
		if(perm_store)*perm_store = 0;
		return error;
	}

	thisenv = &envs[ENVX(sys_getenvid())]; // for lab4's challenge sfork().
  8026d3:	e8 f2 e5 ff ff       	call   800cca <sys_getenvid>
  8026d8:	25 ff 03 00 00       	and    $0x3ff,%eax
  8026dd:	6b d0 7c             	imul   $0x7c,%eax,%edx
  8026e0:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  8026e6:	89 15 04 50 80 00    	mov    %edx,0x805004

	if(from_env_store)*from_env_store = thisenv->env_ipc_from;
  8026ec:	85 f6                	test   %esi,%esi
  8026ee:	74 05                	je     8026f5 <ipc_recv+0x4e>
  8026f0:	8b 42 74             	mov    0x74(%edx),%eax
  8026f3:	89 06                	mov    %eax,(%esi)
	if(perm_store)*perm_store = thisenv->env_ipc_perm;
  8026f5:	85 db                	test   %ebx,%ebx
  8026f7:	74 0a                	je     802703 <ipc_recv+0x5c>
  8026f9:	a1 04 50 80 00       	mov    0x805004,%eax
  8026fe:	8b 40 78             	mov    0x78(%eax),%eax
  802701:	89 03                	mov    %eax,(%ebx)
	return thisenv->env_ipc_value;
  802703:	a1 04 50 80 00       	mov    0x805004,%eax
  802708:	8b 40 70             	mov    0x70(%eax),%eax
}
  80270b:	8d 65 f8             	lea    -0x8(%ebp),%esp
  80270e:	5b                   	pop    %ebx
  80270f:	5e                   	pop    %esi
  802710:	5d                   	pop    %ebp
  802711:	c3                   	ret    
		if(from_env_store)*from_env_store = 0;
  802712:	85 f6                	test   %esi,%esi
  802714:	74 06                	je     80271c <ipc_recv+0x75>
  802716:	c7 06 00 00 00 00    	movl   $0x0,(%esi)
		if(perm_store)*perm_store = 0;
  80271c:	85 db                	test   %ebx,%ebx
  80271e:	74 eb                	je     80270b <ipc_recv+0x64>
  802720:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  802726:	eb e3                	jmp    80270b <ipc_recv+0x64>

00802728 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_try_send a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802728:	f3 0f 1e fb          	endbr32 
  80272c:	55                   	push   %ebp
  80272d:	89 e5                	mov    %esp,%ebp
  80272f:	57                   	push   %edi
  802730:	56                   	push   %esi
  802731:	53                   	push   %ebx
  802732:	83 ec 0c             	sub    $0xc,%esp
  802735:	8b 7d 08             	mov    0x8(%ebp),%edi
  802738:	8b 75 0c             	mov    0xc(%ebp),%esi
  80273b:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// LAB 4: Your code here.
	if(!pg)pg = (void *)UTOP; // 不会进行页面共享，只会sending message。
  80273e:	85 db                	test   %ebx,%ebx
  802740:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802745:	0f 44 d8             	cmove  %eax,%ebx
	int error;
	// Keep trying until it succeeds.
	while((error = sys_ipc_try_send(to_env, val, pg, perm)) < 0){
  802748:	ff 75 14             	pushl  0x14(%ebp)
  80274b:	53                   	push   %ebx
  80274c:	56                   	push   %esi
  80274d:	57                   	push   %edi
  80274e:	e8 62 e7 ff ff       	call   800eb5 <sys_ipc_try_send>
  802753:	83 c4 10             	add    $0x10,%esp
  802756:	85 c0                	test   %eax,%eax
  802758:	79 1e                	jns    802778 <ipc_send+0x50>
        //如果error是没有接收者，那么就会继续尝试send
		if(error != -E_IPC_NOT_RECV){
  80275a:	83 f8 f9             	cmp    $0xfffffff9,%eax
  80275d:	75 07                	jne    802766 <ipc_send+0x3e>
			panic("sys_ipc_try_send:%e", error);
		}
        //但是不是一味的占用cpu，而是尝试一次就释放CPU，等待再次被调度，才会重新send，寻找receiver。
		sys_yield(); // To be CPU-friendly.
  80275f:	e8 89 e5 ff ff       	call   800ced <sys_yield>
  802764:	eb e2                	jmp    802748 <ipc_send+0x20>
			panic("sys_ipc_try_send:%e", error);
  802766:	50                   	push   %eax
  802767:	68 c8 31 80 00       	push   $0x8031c8
  80276c:	6a 3b                	push   $0x3b
  80276e:	68 dc 31 80 00       	push   $0x8031dc
  802773:	e8 96 da ff ff       	call   80020e <_panic>
	}
}
  802778:	8d 65 f4             	lea    -0xc(%ebp),%esp
  80277b:	5b                   	pop    %ebx
  80277c:	5e                   	pop    %esi
  80277d:	5f                   	pop    %edi
  80277e:	5d                   	pop    %ebp
  80277f:	c3                   	ret    

00802780 <ipc_find_env>:
// Find the first environment of the given type.  We'll use this to
// find special environments.
// Returns 0 if no such environment exists.
envid_t
ipc_find_env(enum EnvType type)
{
  802780:	f3 0f 1e fb          	endbr32 
  802784:	55                   	push   %ebp
  802785:	89 e5                	mov    %esp,%ebp
  802787:	8b 4d 08             	mov    0x8(%ebp),%ecx
	int i;
	for (i = 0; i < NENV; i++)
  80278a:	b8 00 00 00 00       	mov    $0x0,%eax
		if (envs[i].env_type == type)
  80278f:	6b d0 7c             	imul   $0x7c,%eax,%edx
  802792:	81 c2 00 00 c0 ee    	add    $0xeec00000,%edx
  802798:	8b 52 50             	mov    0x50(%edx),%edx
  80279b:	39 ca                	cmp    %ecx,%edx
  80279d:	74 11                	je     8027b0 <ipc_find_env+0x30>
	for (i = 0; i < NENV; i++)
  80279f:	83 c0 01             	add    $0x1,%eax
  8027a2:	3d 00 04 00 00       	cmp    $0x400,%eax
  8027a7:	75 e6                	jne    80278f <ipc_find_env+0xf>
			return envs[i].env_id;
	return 0;
  8027a9:	b8 00 00 00 00       	mov    $0x0,%eax
  8027ae:	eb 0b                	jmp    8027bb <ipc_find_env+0x3b>
			return envs[i].env_id;
  8027b0:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8027b3:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8027b8:	8b 40 48             	mov    0x48(%eax),%eax
}
  8027bb:	5d                   	pop    %ebp
  8027bc:	c3                   	ret    

008027bd <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  8027bd:	f3 0f 1e fb          	endbr32 
  8027c1:	55                   	push   %ebp
  8027c2:	89 e5                	mov    %esp,%ebp
  8027c4:	8b 45 08             	mov    0x8(%ebp),%eax
	pte_t pte;

	if (!(uvpd[PDX(v)] & PTE_P))
  8027c7:	89 c2                	mov    %eax,%edx
  8027c9:	c1 ea 16             	shr    $0x16,%edx
  8027cc:	8b 0c 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%ecx
		return 0;
  8027d3:	ba 00 00 00 00       	mov    $0x0,%edx
	if (!(uvpd[PDX(v)] & PTE_P))
  8027d8:	f6 c1 01             	test   $0x1,%cl
  8027db:	74 1c                	je     8027f9 <pageref+0x3c>
	pte = uvpt[PGNUM(v)];
  8027dd:	c1 e8 0c             	shr    $0xc,%eax
  8027e0:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  8027e7:	a8 01                	test   $0x1,%al
  8027e9:	74 0e                	je     8027f9 <pageref+0x3c>
		return 0;
	return pages[PGNUM(pte)].pp_ref;
  8027eb:	c1 e8 0c             	shr    $0xc,%eax
  8027ee:	0f b7 14 c5 04 00 00 	movzwl -0x10fffffc(,%eax,8),%edx
  8027f5:	ef 
  8027f6:	0f b7 d2             	movzwl %dx,%edx
}
  8027f9:	89 d0                	mov    %edx,%eax
  8027fb:	5d                   	pop    %ebp
  8027fc:	c3                   	ret    
  8027fd:	66 90                	xchg   %ax,%ax
  8027ff:	90                   	nop

00802800 <__udivdi3>:
  802800:	f3 0f 1e fb          	endbr32 
  802804:	55                   	push   %ebp
  802805:	57                   	push   %edi
  802806:	56                   	push   %esi
  802807:	53                   	push   %ebx
  802808:	83 ec 1c             	sub    $0x1c,%esp
  80280b:	8b 54 24 3c          	mov    0x3c(%esp),%edx
  80280f:	8b 6c 24 30          	mov    0x30(%esp),%ebp
  802813:	8b 74 24 34          	mov    0x34(%esp),%esi
  802817:	8b 5c 24 38          	mov    0x38(%esp),%ebx
  80281b:	85 d2                	test   %edx,%edx
  80281d:	75 19                	jne    802838 <__udivdi3+0x38>
  80281f:	39 f3                	cmp    %esi,%ebx
  802821:	76 4d                	jbe    802870 <__udivdi3+0x70>
  802823:	31 ff                	xor    %edi,%edi
  802825:	89 e8                	mov    %ebp,%eax
  802827:	89 f2                	mov    %esi,%edx
  802829:	f7 f3                	div    %ebx
  80282b:	89 fa                	mov    %edi,%edx
  80282d:	83 c4 1c             	add    $0x1c,%esp
  802830:	5b                   	pop    %ebx
  802831:	5e                   	pop    %esi
  802832:	5f                   	pop    %edi
  802833:	5d                   	pop    %ebp
  802834:	c3                   	ret    
  802835:	8d 76 00             	lea    0x0(%esi),%esi
  802838:	39 f2                	cmp    %esi,%edx
  80283a:	76 14                	jbe    802850 <__udivdi3+0x50>
  80283c:	31 ff                	xor    %edi,%edi
  80283e:	31 c0                	xor    %eax,%eax
  802840:	89 fa                	mov    %edi,%edx
  802842:	83 c4 1c             	add    $0x1c,%esp
  802845:	5b                   	pop    %ebx
  802846:	5e                   	pop    %esi
  802847:	5f                   	pop    %edi
  802848:	5d                   	pop    %ebp
  802849:	c3                   	ret    
  80284a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802850:	0f bd fa             	bsr    %edx,%edi
  802853:	83 f7 1f             	xor    $0x1f,%edi
  802856:	75 48                	jne    8028a0 <__udivdi3+0xa0>
  802858:	39 f2                	cmp    %esi,%edx
  80285a:	72 06                	jb     802862 <__udivdi3+0x62>
  80285c:	31 c0                	xor    %eax,%eax
  80285e:	39 eb                	cmp    %ebp,%ebx
  802860:	77 de                	ja     802840 <__udivdi3+0x40>
  802862:	b8 01 00 00 00       	mov    $0x1,%eax
  802867:	eb d7                	jmp    802840 <__udivdi3+0x40>
  802869:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802870:	89 d9                	mov    %ebx,%ecx
  802872:	85 db                	test   %ebx,%ebx
  802874:	75 0b                	jne    802881 <__udivdi3+0x81>
  802876:	b8 01 00 00 00       	mov    $0x1,%eax
  80287b:	31 d2                	xor    %edx,%edx
  80287d:	f7 f3                	div    %ebx
  80287f:	89 c1                	mov    %eax,%ecx
  802881:	31 d2                	xor    %edx,%edx
  802883:	89 f0                	mov    %esi,%eax
  802885:	f7 f1                	div    %ecx
  802887:	89 c6                	mov    %eax,%esi
  802889:	89 e8                	mov    %ebp,%eax
  80288b:	89 f7                	mov    %esi,%edi
  80288d:	f7 f1                	div    %ecx
  80288f:	89 fa                	mov    %edi,%edx
  802891:	83 c4 1c             	add    $0x1c,%esp
  802894:	5b                   	pop    %ebx
  802895:	5e                   	pop    %esi
  802896:	5f                   	pop    %edi
  802897:	5d                   	pop    %ebp
  802898:	c3                   	ret    
  802899:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8028a0:	89 f9                	mov    %edi,%ecx
  8028a2:	b8 20 00 00 00       	mov    $0x20,%eax
  8028a7:	29 f8                	sub    %edi,%eax
  8028a9:	d3 e2                	shl    %cl,%edx
  8028ab:	89 54 24 08          	mov    %edx,0x8(%esp)
  8028af:	89 c1                	mov    %eax,%ecx
  8028b1:	89 da                	mov    %ebx,%edx
  8028b3:	d3 ea                	shr    %cl,%edx
  8028b5:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8028b9:	09 d1                	or     %edx,%ecx
  8028bb:	89 f2                	mov    %esi,%edx
  8028bd:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8028c1:	89 f9                	mov    %edi,%ecx
  8028c3:	d3 e3                	shl    %cl,%ebx
  8028c5:	89 c1                	mov    %eax,%ecx
  8028c7:	d3 ea                	shr    %cl,%edx
  8028c9:	89 f9                	mov    %edi,%ecx
  8028cb:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8028cf:	89 eb                	mov    %ebp,%ebx
  8028d1:	d3 e6                	shl    %cl,%esi
  8028d3:	89 c1                	mov    %eax,%ecx
  8028d5:	d3 eb                	shr    %cl,%ebx
  8028d7:	09 de                	or     %ebx,%esi
  8028d9:	89 f0                	mov    %esi,%eax
  8028db:	f7 74 24 08          	divl   0x8(%esp)
  8028df:	89 d6                	mov    %edx,%esi
  8028e1:	89 c3                	mov    %eax,%ebx
  8028e3:	f7 64 24 0c          	mull   0xc(%esp)
  8028e7:	39 d6                	cmp    %edx,%esi
  8028e9:	72 15                	jb     802900 <__udivdi3+0x100>
  8028eb:	89 f9                	mov    %edi,%ecx
  8028ed:	d3 e5                	shl    %cl,%ebp
  8028ef:	39 c5                	cmp    %eax,%ebp
  8028f1:	73 04                	jae    8028f7 <__udivdi3+0xf7>
  8028f3:	39 d6                	cmp    %edx,%esi
  8028f5:	74 09                	je     802900 <__udivdi3+0x100>
  8028f7:	89 d8                	mov    %ebx,%eax
  8028f9:	31 ff                	xor    %edi,%edi
  8028fb:	e9 40 ff ff ff       	jmp    802840 <__udivdi3+0x40>
  802900:	8d 43 ff             	lea    -0x1(%ebx),%eax
  802903:	31 ff                	xor    %edi,%edi
  802905:	e9 36 ff ff ff       	jmp    802840 <__udivdi3+0x40>
  80290a:	66 90                	xchg   %ax,%ax
  80290c:	66 90                	xchg   %ax,%ax
  80290e:	66 90                	xchg   %ax,%ax

00802910 <__umoddi3>:
  802910:	f3 0f 1e fb          	endbr32 
  802914:	55                   	push   %ebp
  802915:	57                   	push   %edi
  802916:	56                   	push   %esi
  802917:	53                   	push   %ebx
  802918:	83 ec 1c             	sub    $0x1c,%esp
  80291b:	8b 44 24 3c          	mov    0x3c(%esp),%eax
  80291f:	8b 74 24 30          	mov    0x30(%esp),%esi
  802923:	8b 5c 24 34          	mov    0x34(%esp),%ebx
  802927:	8b 7c 24 38          	mov    0x38(%esp),%edi
  80292b:	85 c0                	test   %eax,%eax
  80292d:	75 19                	jne    802948 <__umoddi3+0x38>
  80292f:	39 df                	cmp    %ebx,%edi
  802931:	76 5d                	jbe    802990 <__umoddi3+0x80>
  802933:	89 f0                	mov    %esi,%eax
  802935:	89 da                	mov    %ebx,%edx
  802937:	f7 f7                	div    %edi
  802939:	89 d0                	mov    %edx,%eax
  80293b:	31 d2                	xor    %edx,%edx
  80293d:	83 c4 1c             	add    $0x1c,%esp
  802940:	5b                   	pop    %ebx
  802941:	5e                   	pop    %esi
  802942:	5f                   	pop    %edi
  802943:	5d                   	pop    %ebp
  802944:	c3                   	ret    
  802945:	8d 76 00             	lea    0x0(%esi),%esi
  802948:	89 f2                	mov    %esi,%edx
  80294a:	39 d8                	cmp    %ebx,%eax
  80294c:	76 12                	jbe    802960 <__umoddi3+0x50>
  80294e:	89 f0                	mov    %esi,%eax
  802950:	89 da                	mov    %ebx,%edx
  802952:	83 c4 1c             	add    $0x1c,%esp
  802955:	5b                   	pop    %ebx
  802956:	5e                   	pop    %esi
  802957:	5f                   	pop    %edi
  802958:	5d                   	pop    %ebp
  802959:	c3                   	ret    
  80295a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802960:	0f bd e8             	bsr    %eax,%ebp
  802963:	83 f5 1f             	xor    $0x1f,%ebp
  802966:	75 50                	jne    8029b8 <__umoddi3+0xa8>
  802968:	39 d8                	cmp    %ebx,%eax
  80296a:	0f 82 e0 00 00 00    	jb     802a50 <__umoddi3+0x140>
  802970:	89 d9                	mov    %ebx,%ecx
  802972:	39 f7                	cmp    %esi,%edi
  802974:	0f 86 d6 00 00 00    	jbe    802a50 <__umoddi3+0x140>
  80297a:	89 d0                	mov    %edx,%eax
  80297c:	89 ca                	mov    %ecx,%edx
  80297e:	83 c4 1c             	add    $0x1c,%esp
  802981:	5b                   	pop    %ebx
  802982:	5e                   	pop    %esi
  802983:	5f                   	pop    %edi
  802984:	5d                   	pop    %ebp
  802985:	c3                   	ret    
  802986:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  80298d:	8d 76 00             	lea    0x0(%esi),%esi
  802990:	89 fd                	mov    %edi,%ebp
  802992:	85 ff                	test   %edi,%edi
  802994:	75 0b                	jne    8029a1 <__umoddi3+0x91>
  802996:	b8 01 00 00 00       	mov    $0x1,%eax
  80299b:	31 d2                	xor    %edx,%edx
  80299d:	f7 f7                	div    %edi
  80299f:	89 c5                	mov    %eax,%ebp
  8029a1:	89 d8                	mov    %ebx,%eax
  8029a3:	31 d2                	xor    %edx,%edx
  8029a5:	f7 f5                	div    %ebp
  8029a7:	89 f0                	mov    %esi,%eax
  8029a9:	f7 f5                	div    %ebp
  8029ab:	89 d0                	mov    %edx,%eax
  8029ad:	31 d2                	xor    %edx,%edx
  8029af:	eb 8c                	jmp    80293d <__umoddi3+0x2d>
  8029b1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8029b8:	89 e9                	mov    %ebp,%ecx
  8029ba:	ba 20 00 00 00       	mov    $0x20,%edx
  8029bf:	29 ea                	sub    %ebp,%edx
  8029c1:	d3 e0                	shl    %cl,%eax
  8029c3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8029c7:	89 d1                	mov    %edx,%ecx
  8029c9:	89 f8                	mov    %edi,%eax
  8029cb:	d3 e8                	shr    %cl,%eax
  8029cd:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8029d1:	89 54 24 04          	mov    %edx,0x4(%esp)
  8029d5:	8b 54 24 04          	mov    0x4(%esp),%edx
  8029d9:	09 c1                	or     %eax,%ecx
  8029db:	89 d8                	mov    %ebx,%eax
  8029dd:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8029e1:	89 e9                	mov    %ebp,%ecx
  8029e3:	d3 e7                	shl    %cl,%edi
  8029e5:	89 d1                	mov    %edx,%ecx
  8029e7:	d3 e8                	shr    %cl,%eax
  8029e9:	89 e9                	mov    %ebp,%ecx
  8029eb:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  8029ef:	d3 e3                	shl    %cl,%ebx
  8029f1:	89 c7                	mov    %eax,%edi
  8029f3:	89 d1                	mov    %edx,%ecx
  8029f5:	89 f0                	mov    %esi,%eax
  8029f7:	d3 e8                	shr    %cl,%eax
  8029f9:	89 e9                	mov    %ebp,%ecx
  8029fb:	89 fa                	mov    %edi,%edx
  8029fd:	d3 e6                	shl    %cl,%esi
  8029ff:	09 d8                	or     %ebx,%eax
  802a01:	f7 74 24 08          	divl   0x8(%esp)
  802a05:	89 d1                	mov    %edx,%ecx
  802a07:	89 f3                	mov    %esi,%ebx
  802a09:	f7 64 24 0c          	mull   0xc(%esp)
  802a0d:	89 c6                	mov    %eax,%esi
  802a0f:	89 d7                	mov    %edx,%edi
  802a11:	39 d1                	cmp    %edx,%ecx
  802a13:	72 06                	jb     802a1b <__umoddi3+0x10b>
  802a15:	75 10                	jne    802a27 <__umoddi3+0x117>
  802a17:	39 c3                	cmp    %eax,%ebx
  802a19:	73 0c                	jae    802a27 <__umoddi3+0x117>
  802a1b:	2b 44 24 0c          	sub    0xc(%esp),%eax
  802a1f:	1b 54 24 08          	sbb    0x8(%esp),%edx
  802a23:	89 d7                	mov    %edx,%edi
  802a25:	89 c6                	mov    %eax,%esi
  802a27:	89 ca                	mov    %ecx,%edx
  802a29:	0f b6 4c 24 04       	movzbl 0x4(%esp),%ecx
  802a2e:	29 f3                	sub    %esi,%ebx
  802a30:	19 fa                	sbb    %edi,%edx
  802a32:	89 d0                	mov    %edx,%eax
  802a34:	d3 e0                	shl    %cl,%eax
  802a36:	89 e9                	mov    %ebp,%ecx
  802a38:	d3 eb                	shr    %cl,%ebx
  802a3a:	d3 ea                	shr    %cl,%edx
  802a3c:	09 d8                	or     %ebx,%eax
  802a3e:	83 c4 1c             	add    $0x1c,%esp
  802a41:	5b                   	pop    %ebx
  802a42:	5e                   	pop    %esi
  802a43:	5f                   	pop    %edi
  802a44:	5d                   	pop    %ebp
  802a45:	c3                   	ret    
  802a46:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802a4d:	8d 76 00             	lea    0x0(%esi),%esi
  802a50:	29 fe                	sub    %edi,%esi
  802a52:	19 c3                	sbb    %eax,%ebx
  802a54:	89 f2                	mov    %esi,%edx
  802a56:	89 d9                	mov    %ebx,%ecx
  802a58:	e9 1d ff ff ff       	jmp    80297a <__umoddi3+0x6a>
